Upload
tesla-dax
View
244
Download
0
Embed Size (px)
Citation preview
8/12/2019 OpenSCAD Class
1/33
Introduction to OpenSCAD
Steve Graves
8/12/2019 OpenSCAD Class
2/33
Teaching Goals Concepts Not Nuts and Bolts Ask questions. Classes are for active learning. There are
pro a l! "an! levels of e#perience in class. Don$t e sh!%ever!one &as a nu ie once.
If a question refers to so"ething co"ing up% it is a goodquestion. But I "ight defer it.
I plan on la!ing the foundation first% ut have several usefulconcepts that go a little further than the asics. Going to tr! totouch all of the".
I e#pect that after this class !ou &ill feel confident to create asi"ple o 'ect.
8/12/2019 OpenSCAD Class
3/33
(se the )anual I a" not going to regurgitate the "anual. Concepts are "ore i"portant than details. In the real &orld% open ooks are allo&ed. (se help "enu to open "anual. Don$t clutter "ind &ith para"eter details. It &ill
happen auto"aticall!.
8/12/2019 OpenSCAD Class
4/33
Concepts *hat is OpenSCAD+ *hat is the ,D printing process and ho& does OpenSCAD fit in
it+
*hat are asic concepts for all progra"s that create ,D o 'ects+ *hat is OpenSCAD$s s!nta# and ho& is it unique+ *hat are so"e OpenSCAD user interface tips+ *hat are so"e design patterns+ (se Divide and Conquer. Don$t reinvent the &heel.
8/12/2019 OpenSCAD Class
5/33
*hat is OpenSCAD+ -rogra" to design ,D o 'ects. It has eco"e the defacto
standard on thingiverse for para"etric designs. Open source and free.
Other free progra"s are Blender% Sketch(p% reeCad and/eeksCad
OpenSCAD generates o 'ects fro" progra"s0scripts+1 andis "ostl! non2interactive.
A progra" "eans para"etric designs that are"athe"aticall! precise.
8/12/2019 OpenSCAD Class
6/33
OpenSCAD (ser Interface 3eft hand side is te#t edit &indo& for &riting code. Other
te#t editors can e used. 4e"acs is a good e#a"ple. 5ight hand side is &indo& for inspecting rendered ,D
o 'ect. O 'ect in right hand &indo& can e "anipulated using
standard OpenG3 "ouse "oves. 3eft "ouse allo&s one to rotate o 'ect. 5ight "ouse pans. )iddle "ouse or &heel 6oo"s.
8/12/2019 OpenSCAD Class
7/33
*hat is the ,D -rinting -rocess+ ,D o 'ect is designed 0OpenSCAD1 An ST3 file is e#ported. A slicer progra" reaks ST3 file into la!ers and
generates G code. G code is sent to printer.
8/12/2019 OpenSCAD Class
8/33
General ,D O 'ect Creation Concepts 7e! concept is 8Transfor"ed Shapes are Co" ined9 into
ne& "ore co"ple# shapes. Co"ple# o 'ects are created fro" si"ple 8Shapes9 called
pri"itives. Si"ple and co"ple# shapes are "odified &ith
8Transfor"ations9 like translate% si6e% color. -ri"itive shapes are 8Co" ined9 in various &a!s using
oolean logic and other "ore co"plicated functions. Au#iliar! functions are used to do "ath% etc.
8/12/2019 OpenSCAD Class
9/33
,D 0and :D1 -ri"itives Cu e Sphere C!linder -ol!hedron Square 0:D1
Circle 0:D1 -ol!gon 0:D1
8/12/2019 OpenSCAD Class
10/33
)aking ,D fro" :D :D pri"itives are turned into ,D ! e#trusion T&o asic t!pes of e#trusion linear;e#trude rotate;e#trude
8/12/2019 OpenSCAD Class
11/33
Co" ining Shapes (nion 0All shapes added together1 Difference 0Shapes after < st shape are su tracted1 Intersection 0Intersection of all shapes1 )inko&ski 0 unction &ith interesting properties to
add t&o shapes1 /ull 0=nclose "ultiple shapes in "ini"u" shape1
8/12/2019 OpenSCAD Class
12/33
Transfor"ing Shapes Scale 5esi6e 5otate Translate )irror
)ult"atri# Color
8/12/2019 OpenSCAD Class
13/33
OpenSCAD ,D O 'ect Creation
,D o 'ects are created using the general pattern
Co" ine01>
optTransfor"01 optTransfor"01 ... Shape01?
optTransfor"01 optTransfor"01 ... Shape01?
...
@*ork fro" end of line to&ard front of line.
*ork fro" inner"ost to outer"ost
8/12/2019 OpenSCAD Class
14/33
S!nta# unctions 0"odules1 are overloaded. aria les have unusual scope. aria les do not store shapes. Shapes are i"plicit entities.
Arra!s are used a lot to represent points or vectors. er! often as para"eters to functions. Be&are 5e"e" er to use as &ell as 01. In"ost cases there is no s!nta# error if !ou don$t.
3ines are ter"inated &ith se"icolon.
A 8line9 of code has a shape 'ust efore the se"icolon. That shapecan e 8transfor"ed9 ! functions efore it. These functions have nose"icolons. The transfor"ations are applied in reverse order 0closestfirst and &orking ack1.
8/12/2019 OpenSCAD Class
15/33
)ore on s!nta# *e can learn "ore a out the &orking s!nta# !
looking at the s!nta# for a "odule. )odules i"plicitl! return shapes. So a "odule "ust create a shape internall! or get
one 8passed9 to it. Shapes are 8passed9 as children% not para"eters.
5e"e" er shapes are not stored in varia les.
8/12/2019 OpenSCAD Class
16/33
8/12/2019 OpenSCAD Class
17/33
8/12/2019 OpenSCAD Class
18/33
Calling a "odule as a Co" ine
Na"e0-ara
Child0F1?
Child0 % call to another "odule% etc.
8/12/2019 OpenSCAD Class
19/33
Calling a "odule as transfor"
Na"e0opt-ara
8/12/2019 OpenSCAD Class
20/33
Calling "odule as shape
Na"e0opt-ara
8/12/2019 OpenSCAD Class
21/33
(ser Interface Tips (se 8Thro&n Together9 vie& and 8Co"pile9 for a quick
and dirt! look at design Break large s!ste"s into files to est use a ove technique.
(se .stl files to speed up rendering in co"ple# designs. (se 8Co"pile and 5ender9 for "ore refined look 0and
longer &ait for processing1 There is a co""entEunco""ent function Set fs high during develop"ent
8/12/2019 OpenSCAD Class
22/33
(seful Design -atterns Identif! all the para"eters for o 'ect0s1 eing
created Assign a varia le to each para"eter efore creating
design
8/12/2019 OpenSCAD Class
23/33
)ore Design -atterns
difference01>
union01>
union child0F1?
union child0
8/12/2019 OpenSCAD Class
24/33
)ore Design -atterns
"odule oneShape01>
...?
@
"odule shapeT&o01>
...?
@
union01>
transfor"ations01 shapeOne01?
transfor"ations01 shapeT&o01?
@
8/12/2019 OpenSCAD Class
25/33
Divide and Conquer Shapes are o vious )oves and rotates can also e divided. Create parts
in local coordinate s!ste"s% then "ove the" into
position in glo al coordinate s!ste".
8/12/2019 OpenSCAD Class
26/33
Don$t 5einvent the *heel So"e od! has alread! &ritten a 8*heel9 "odule. (se uiltin )CAD li rar! Search thingiverse Search the Internet
8/12/2019 OpenSCAD Class
27/33
Tip (se fn for "ore shapes The fn para"eter can e used &ith c!linder to
create shapes &ith sides.
8/12/2019 OpenSCAD Class
28/33
)inko&ski 0Operation 1 er! useful ut hard to understand. One shape is added to another shape at ever! point in the
shape. Order doesn$t "atter.
Si"ilar to "atri# addition. The additions at the surface are the onl! ones that have an
effect. I"agine one shape eing s"eared onto the other shape. *arning )inko&ski is incredi l! slo& &ith spheres.
8/12/2019 OpenSCAD Class
29/33
)inko&ski =#a"ple
8/12/2019 OpenSCAD Class
30/33
8/12/2019 OpenSCAD Class
31/33
(se "odule for shape 8varia les9
/* * This creates a shell of given thickness * around an arbitrary shape */module shell(thickness){ difference(){ minkowski(){ child(0); sphere(r thickness! center true); " child(0); ""shell(#0){ cylinder(r $%);"
8/12/2019 OpenSCAD Class
32/33
Creating "anifold designs )anifold effectivel! "eans &ater2tight. 3eaks happen at shared oundaries. Shared
oundaries also slo& do&n processing. =#tend o 'ects that su tract e!ond surface. =ither use 8glue9 o 'ects or e#tend surfaces into
other o 'ects for unions. Spheres can so"eti"es fail to e "anifold. (se
circle and rotate;e#trude instead.
8/12/2019 OpenSCAD Class
33/33
)ore on "anifold designs (se thro&n together and co"pile to see
questiona le oundaries.