You are on page 1of 140

Practical Solid Modeling

For 3D Printing
With OpenSCAD
Ed Nisley KE4N!
ed"nisley#po$o%"co&
so'tsolder"co&
(
S)*id+rench
Septe&$er ,-.3
2/140
!pco&ing E/ents

De'ining the 0er&s

Practical 1 Solid Modeling 1 3D Printing 1 OpenSCAD

Constr*cti/e Solid 2eo&etry

CS2 Solids 1 Operations 1 0rans'or&ations

OpenSCAD 3De$*gging4 1 5terators 1 Conditionals

Modeling Printa$le O$6ects

2eo&etric 7 Process Constraints

8ole Cali$ration 7 Co&pensation

9ridging 1 O/erhang 1 S*pport Str*ct*res

Other Fancy St*''


3/140
De'ining the 0er&s
4/140
Practical
prac1ti1cal
ad6ecti/e : pra;ti;<l:
O' or concerned +ith
the act*al doing or *se o' so&ething
rather than +ith theory and ideas
0h*s sayeth 2oogle
define: practical
5/140
C*sto& Parts
6/140
=epair Parts
7/140
F*n St*''
8/140
Other People>s ?5&@practical St*''
9/140
Pro6ect Details
C*sto& Parts

Propane AD +rench

Photodiode 'i%t*re

8el&et &irror

Microscope ring light

Microscope ca&era

Ca&era &acro lens

A&ate*r radio 2PS

9attery 'i%t*re
=epair Parts

Caliper th*&$+heel

FreeBer shel' $rac;et

9roo& handle

Cac**& hose cla&p

9ar cla&p handle


10/140
Pro6ect Details
F*n St*''

Ner' Pistol

CO, Caps*le Fins

0*% Coo;ie C*tter

Concrete 9loc;s

0riple Cylinder 0hing

A*ilting Pin Caps


Other Peoples> St*''

Dr" Who C*tter:Press

Knot

Fat 9*n$*n

Chal; people

Co&panion C*$e

Stan'ord 9*nny

Octop*s

3D Portrait
11/140
Solid Modeling
""" is a consistent set o' principles
'or &athe&atical and co&p*ter &odeling o'
threeDdi&ensional solids"
Solid &odeling is disting*ished
'ro& related areas o' geo&etric &odeling and
co&p*ter graphics $y
its e&phasis on physical 'idelity"
0h*s sayeth 2oogle
define: solid modeling
12/140
0hree Di&ensional Solid Models
13/140
E&phasis on Physical Fidelity
14/140
3D Printing
Additi/e &an*'act*ring or 3D printing is a
process o' &a;ing a threeDdi&ensional solid
o$6ect o' /irt*ally any shape 'ro& a digital &odel"
3D printing is achie/ed *sing an
additi/e processE +here s*ccessi/e layers o'
&aterial are laid do+n in di''erent shapes"
0h*s sayeth Wi;ipedia
httpF::en"+i;ipedia"org:+i;i:3DGprinting
15/140
3F*sed Deposition4 3D Printing

F*sed Fila&ent Fa$rication

2lori'ied 2l*e 2*n 0echnology H

9e+are the trade&ar; 7 5P &ine'ield


16/140
3D Printing !p Close
0*% Coo;ie C*tter
(
0he Mo/ie
httpF::so'tsolder"co&:,-..:-I:-J:t*%Dcoo;ieDc*tter:
17/140
OpenSCAD
OpenSCAD is a so't+are 'or
creating solid 3D CAD &odels"
(
5t is """ a 3DDco&piler that
reads in a script 'ile descri$ing the o$6ect
and
renders the 3D &odel
0h*s sayeth OpenSCAD
+++"openscad"org
18/140
OpenSCAD
0h*s it &ight $e
the application yo* are loo;ing 'or
+hen yo* are planning to
create 3D &odels o' &achine parts
(
$*t pretty s*re KitL is not """ 'or
creating co&p*terDani&ated &o/ies"
0h*s sayeth OpenSCAD
+++"openscad"org:a$o*t"ht&l
19/140
OpenSCAD Machine Models
MendelI-
$y nophead
30he OpenScad &odel no+ incl*des e/erything
in the ;itE +hich is e/erything needed to $*ild the
&achine apart 'ro& so&e stic;y tape4
20/140
OpenSCAD Machine Models
9ea& engine
solid &odel
$y Da/id
Po+ell
3it>s 6*st a
&oc;*p and
not intended
'or 3d
printing4
21/140
OpenSCAD ?5&@Practical Models
S*perShapes
$y Willia&AAda&s
3Mo* also get the
proced*ral te%t*re
&apping
chec;er$oard
patternE thro+n in
'or 'ree"4
8e also does /ery
practical st*''"""
22/140
Constr*cti/e Solid 2eo&etry
3CS24
23/140
Constr*cti/e Solid 2eo&etry
H an o$6ect is constr*cted 'ro& pri&iti/es
$y &eans o' allo+a$le operationsE
+hich are """ 9oolean operations on setsF
*nionE intersection and di''erence"
0h*s sayeth Wi;ipedia
httpF::en"+i;ipedia"org:+i;i:Constr*cti/eGsolidGgeo&etry
24/140
CS2 Pri&iti/es
OpenSCADF c*$e cylinder sphere
25/140
OpenSCAD Color Sche&e
26/140
OpenSCAD Editor Pre'erences
27/140
OpenSCAD Design Option
28/140
CS2 Pri&iti/eF C*$e
Ne't drag O rotate horiB
Shi'tDNe't drag O rotate /ert
=ight drag O &o/e
Scroll +heel O Boo&
CtrlD- O reset rotation
CtrlDP O reset &o/e
29/140
CS2 Pri&iti/eF Cylinder
De'ine n*&$er o' sidesF
P'nO3 Q triang*lar
P'nOR Q he%agonal ?n*tsS@
P'nOT Q octagonal
30/140
CS2 Pri&iti/eF Cylinder
De'ine n*&$er o' sidesF
P'nO3 Q triang*lar
P'nOR Q he%agonal ?n*tsS@
P'nOT Q octagonal
31/140
CS2 Pri&iti/eF Sphere
Control 'acets at e)*atorF
P'a O &ini&*& angle
P's O &ini&*& siBe
P'n O act*al n*&$er
32/140
CS2 OperationF !nion
33/140
CS2 OperationF Di''erence
34/140
CS2 OperationF Di''erence
FI O OpenCS2 /ie+
F., O 30hro+n 0ogether4
35/140
CS2 OperationF Di''erence
36/140
CS2 OperationF Di''erence
FI O OpenCS2 /ie+
F., O 30hro+n 0ogether4
37/140
CS2 OperationF 5ntersection
38/140
Essential 0rans'or&ations

0ranslate?K%EyEBL@

=otate?K%EyEBL@

=otate?angle@ aro*nd a%is

Color ?3na&e4@ or Color?3na&e4Ealpha@

3na&e4 not case sensiti/eS

Mirror?K%EyEBL@

%yB O nor&al o' &irror plane thro*gh origin

Scale?K%EyEBL@

=esiBe?K%EyEBL@
39/140
Dish+asher =ac; Protector
httpF::so'tsolder"co&:,-.3:-,:-4:dish+asherDrac;DprotectorsDintoDtheD&a+:
40/140
Dish+asher =ac; Protector
httpF::so'tsolder"co&:,-.3:-,:-4:dish+asherDrac;DprotectorsDintoDtheD&a+:
41/140
0ranslate?K%EyEBL@
42/140
=otate?K%EyEBL@
43/140
Di''erenceF FI Cie+
44/140
Di''erenceF F., Cie+
45/140
Di''erenceF FI Cie+
46/140
Di''erenceF F., Cie+
47/140
?=e@Co&pileF FU

Fast pre/ie+ &ode

Si&ple depth $*''er

No act*al 3D &odel

Colors as e%pected

Not e%porta$leS
48/140
Co&pile 7 =enderF FR

Solid Model 2eneration

F*ll 3D rendering

All geo&etry resol/ed

Single color

May not $e &ani'old

5' yo* scre+ed *p

E%porta$leS
49/140
S0N File 2eneration

ASC55 'ile 'or&at

8*ge 'iles

0hat>s all it ta;es


50/140
S0N File Contents

0riangle tessellation

No c*r/esS

No 3&odel4 content

No s&arts

S*r'ace nor&als

For each triangle

Mo* ha/e no control


51/140
OpenSCAD
CS2 3De$*gging4
52/140
Ordinary FI Cie+
53/140
8ighlighting an O$6ectF V
54/140
8ighlighting an O$6ectF V in FI
55/140
8ighlightingF V in F.,
56/140
What Mo* E%pected
57/140
What Mo* 2ot
58/140
Where>s the Missing 8ole in F.,W
59/140
8ighlightingF V in F.,
60/140
Where Did E/erything 2oW
61/140
E/erything in F., Cie+
62/140
E/erything 8ighlighted C*$eF FI
63/140
De$*g Modi'ierF X in FI
64/140
OpenSCAD NonD9*gging

!se an e%ternal editorS

8ide the OpenSCAD editor pane

Add : change one tiny little thing at a ti&e

Editor>s !ndo '*nction +ill $e yo*r 9FF

!se +hat &eager assistance yo* ha/e

F.,F 0hro+n 0ogether /ie+

Modi'ier charactersF X and V

echo?str?30hisF 4Ena&e@@ sho+s co&p*ted /al*es

Keep it si&ple and &a;e it o$/io*s


65/140
OpenSCAD
5s
Not
C
66/140
OpenSCAD Is Not C

Si&ilar synta%E vastly di''erent se&antics

Declarati/eE not proced*ral

Descri$es geo&etryE not process

Nac;s &any 3high le/el4 'eat*res

0his is not a $*g

Pro$a$ly a +riteDonly lang*age

Not easy to /is*aliBe the e''ects

Mod*les not easily reD*sa$le d*e to geo&etry

2lo$al : local /aria$les /s" para&eters


67/140
0he $etter yo* are
at C : CYY : Za/a : +hate/er
(
0he &ore tro*$le yo* are
a$o*t to ha/e
+ith OpenSCAD
68/140
5teration

'or ?i O KstartFincre&entFendL@

Don>t get cle/er +ith incre&ent /al*e

!se integersE co&p*te 'loats in loop

'or ?i O KlistE o'E &anyE /al*esE inE aE /ectorL@

Don>t get cle/er +ith nested /ectors O arrays

5&plicit *nion?@ o' all o$6ects +ithin loop

!se intersectionG'or?@ 'or intersections"""


69/140
Sin; Strainer
70/140
Sin; Strainer
71/140
De'ine the Di&ensionsS
Code sho*ld ha/e only
the standard &agic
constants
H -E .E and ,
H I-E .T-E 3R-
H maybe s)rt?,@
72/140
Create a Mod*le
D*&p /al*es to console
73/140
0ry a Si&ple Case
2eo&etric !nit
74/140
D*&p Cal*es to 3Console4
Module cache size: 0 modules
Compiling design (CSG Tree generation)...
C!": #$ia: #% &0% # holes: #% '
Compiling design (CSG (roducts generation)...
(ol)SetCache hit:
c)linder(*fn+0%*fa+,&%*fs+&%h+'%r,+-'%r&
(ol)SetCache hit:
c)linder(*fn+0%*fa+,&%*fs+&%h+'.&%r,+.%r
/ snippage ...
75/140
5terate O/er All =ings
76/140
Conditionals

i' ?this operator that@

As in CF do*$leDe)*al OO e)*ality operator

!se to select o$6ectsE not /al*es

i' ?this OO 3string /al*e4@

Case &atters

/al*e O ?this operator that@ W i'Gtr*e F i'G'alse

!se to select /al*esE not o$6ects

=e&e&$erF 0here Are No Caria$lesS


77/140
Constr*ct a 8andle
78/140
Conditional O$6ect 5nstances
Mod*le O
any &*ltipleD*se
o$6ect
79/140
Nayo*t O Sho+
80/140
Nayo*t O 9*ild
81/140
Opti&iBe 9*ild Plat'or& Nayo*t
82/140
My 39est Practices4

OpenSCAD is not a progra&&ing lang*age

Don>t" 9e" Cle/er"

5' yo* &*st $e cle/erE preprocess in PythonE et" al"

0here Are No Caria$les

Only de'ined constants +ith glo$al scope

2et o/er it

8a/e a conditional layo*t 'or e/ery &od*le

0hin; o' it as a *nit test harness

Proceed in tiny steps


83/140
Modeling Printa$le O$6ects
84/140
2eo&etric =e)*ire&ents

Closed s*r'ace

3Watertight4 o$6ects

Consistent Nor&als

All ai&ed o*t+ard

,DMani'old

E%actly , 'aces : edge

No coincident 'aces
httpF::reprap"org:+i;i:SeparateGpageGonGtheG)*estion
httpsF::en"+i;ipedia"org:+i;i:FileFAc&eG;leinG$ottle"6pg
85/140
What>s Wrong With 0his Pict*reW
9eginning 2oogle S;etch!p 'or 3D Printing httpF::+++"apress"co&:IJT.43-,33R.I
httpF::reprap"org:+i;i:S;etch*pGModelingG'orG3dGPrinting
httpF::reprap"org:+i;i:ArtGo'Gill*sion

Not a closed s*r'ace

Not 3+atertight4

5nconsistent nor&als

Easy to seeW

May$e in this &odel"""

9oo; /ersion is OK

CS2 O 3D /ol*&es

Mesh O ,D s*r'aces
86/140
Not ,DMani'oldF 4 Sides:Edge
87/140
Not ,DMani'oldF Coincident Faces
88/140
Not ,DMani'oldF Coincident Faces
89/140
What>s Wrong With 0his Pict*reW
httpF::so'tsolder"co&:,-..:-T:,3:ne&aD.JDstepperD&otorD&o*nt
:
90/140
Solid Model Q 2DCode
httpF::'a$&ethe*s"crsndoo"co&:+i;i:inde%"php:S;ein'orgeGS;einlayer
httpF::so'tsolder"co&:,-..:-I:-U:openscadD/sDs;ein'orgeD4-D$og*sDgDcode:
91/140
What>s Wrong With 0his Pict*reW
httpF::so'tsolder"co&:,-..:-T:,3:ne&aD.JDstepperD&otorD&o*nt
:
92/140
What>s Wrong With 0his Pict*reW
httpF::so'tsolder"co&:,-..:-T:,3:ne&aD.JDstepperD&otorD&o*nt
:
8o+
Many
FacesW
93/140
What>s Right With 0his Pict*reW
httpF::so'tsolder"co&:,-..:-T:,3:ne&aD.JDstepperD&otorD&o*nt
:
94/140
What>s Right With 0his Pict*reW
httpF::so'tsolder"co&:,-..:-T:,3:ne&aD.JDstepperD&otorD&o*nt
:
One
Solid
9loc;S
95/140
What>s Wrong With 0his Pict*reW
96/140
What>s Wrong With 0his Pict*reW
3Shi&&er4
is the tipo''
97/140
What>s Wrong With 0his Pict*reW
Coincident
FacesS
98/140
F., Cie+
Coincident
FacesS
99/140
What>s =ight With 0his Pict*reW
Protr*sion O -".
100/140
What Does 5t 0a;e 0o 9e =ightW
cylinder?rO8andlePegOD:,E
hO3[Plate0hic;E
centerOtr*e@\
translate?K=ingDia:,E-EDProtr*sionL@
cylinder?rO8oleDia:,E
hO?0hic;ness Y ,[Protr*sion@@\
101/140
What>s =ight With 0his Pict*reW
102/140
Process Ni&itations
103/140
F*nda&ental SiBes
104/140
F*nda&ental SiBes
M*stache
hairS
105/140
E%tr*der Cali$ration
httpF::so'tsolder"co&:,-.3:-4:.R:&a;ergearD&,D'*nda&entalDtestDo$6ect:
106/140
E%tr*der Cali$ration
httpF::so'tsolder"co&:,-.3:-4:.R:&a;ergearD&,D'*nda&entalDtestDo$6ect:
107/140
S&allest Possi$le Feat*re
108/140
!na/oida$le 2apS
109/140
Wall Width 0est Piece
httpF::+++"thingi/erse"co&:thingFTTUI
110/140
8ole 7 Pillar 0ests
httpF::+++"thingi/erse"co&:thingF4,T--
111/140
8ole 7 Pillar Cali$ration
httpF::so'tsolder"co&:,-.3:-4:,.:&a;ergearD&,DpostDandDholeDcali$rationDtestDo$6ects:
112/140
8ole SiBe Co&pensation
9ased on Nophead>s Polygonal 8oles
httpF::hydraraptor"$logspot"co&:,-..:-,:polyholes"ht&l
!ole0indage + 0.&1
module (ol)C)l($ia%!eight%2orceSides+0) 3
Sides + (2orceSides 4+ 0) 5
2orceSides : (ceil($ia) 6 &)1
2i7$ia + $ia 8 cos(,908Sides)1
c)linder(r+(2i7$ia 6 !ole0indage)8&%
h+!eight%*fn+Sides)1
:
113/140
8ole SiBe 0est Piece
httpF::so'tsolder"co&:,-..:..:,U:thingDoD&aticDs&allDholeDcali$ration:
114/140
8ole SiBe 0est Piece
httpF::so'tsolder"co&:,-..:..:,U:thingDoD&aticDs&allDholeDcali$ration:
Circ*&scri$es
original dia&eter
115/140
9ridge 0est Piece
httpF::+++"thingi/erse"co&:thingFIT-4
116/140
9ridge 0est
httpF::+++"thingi/erse"co&:thingFIT-4
117/140
O/erhang
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
118/140
O/erhang /s" 9ridging
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
119/140
O/erhang and 9ridging
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
120/140
O/erhang and 9ridging
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
121/140
S*pport Str*ct*resS
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
122/140
9ridge ?W@ S*pport Str*ct*re
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
123/140
S*pport Str*ct*reF Oops
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
124/140
S*pport Str*ct*re
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
125/140
O/erhang S*pport Str*ct*re
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
126/140
S*pport Str*ct*resS
httpF::so'tsolder"co&:,-.,:-.:-3:planetD$i;eDs*per'lashDto*rDeasyD&o*nt:
127/140
9ridge ?W@ S*pport Str*ct*re
httpF::so'tsolder"co&:,-.3:-,:-4:dish+asherDrac;DprotectorsDintoDtheD&a+:
128/140
S*pport Str*ct*re
httpF::so'tsolder"co&:,-.3:-,:-4:dish+asherDrac;DprotectorsDintoDtheD&a+:
129/140
=e&o/ing S*pport Str*ct*res
httpF::so'tsolder"co&:,-.3:-,:-4:dish+asherDrac;DprotectorsDintoDtheD&a+:
130/140
Other Fancy St*''
131/140
Polygons and Polyhedrons

polygon?H@

Nist o' points

linearGe%tr*de?"""@

polyhedron?H@

Nist o' points

Nist o' triangles

Calc*late the pointsS

5nternal precision

Direct &eas*re&entW
httpF::so'tsolder"co&:,-.,:-4:-U:;gD*/3dDgps/oiceD$atteryDpac;Dalign&entDl*gs:
132/140
D]F 5&port 7 E%port

i&portGd%'?@ and pro6ection?@

5n theoryE yo* can i&port co&ple% diagra&s

5n practiceE it>s very '*ssy a$o*t content

2ood l*c;"""
133/140
8*ll

h*ll?"""@

,D 'ig*res in ]M

polygon?@

Circle?@E s)*are?@

linearGe%tr*de?"""@
httpF::so'tsolder"co&:,-.,:..:-,:+hirlpoolDre'rigeratorDreplace&entD'reeBerDshel'D$rac;et:
134/140
O*tlines Fro& Dra+ings

Peri&eter Q Shape

Start 'ro& EPS

Ni&ited resol*tion

Maintain chirality

A si&ple &atter o' so't+are

5&age&agic; F0WS

&in;o+s;i?@ s*&
httpF::so'tsolder"co&:,-..:-I:-J:t*%Dcoo;ieDc*tter:
135/140
S*r'ace 8eight Maps

s*r'ace?'ileO"""@

Cery speci'ic 'ile 'or&at

T $it grayscale Q height

MesE ,UR Shades o' 2rey"""

A si&ple &atter o' so't+are

5&age&agic; F0WS

9ash scripting

]M resol*tion li&it
httpF::so'tsolder"co&:,-.,:..:-I:a*to&atedDcoo;ieDc*ttersDp*ttingDitDallDtogether:

Start si&ple

Keep it si&ple

Math is yo*r 'riend

Meas*re&entsS

Calc*late everything

Slice 7 Ceri'y 2DCode

0hat>s another tal;"""

Always /eri'y $e'ore printing

9*ild St*'' Mo* NeedS


Finally """
137/140
reprap"org
+++"openscad"org
My Along the G-Code Way col*&n
5n Digital Machinist &agaBine
AndE o' co*rse"""
so'tsolder"co&
More 5n'o
138/140
So&e +e$ i&ages pro$a$ly copyrightedE $*t
sho+n 7 attri$*ted here *nder 3'air *se4
K+hate/er that isL
0he rest is &y o+n +or;
^
0his +or; is licensed *nder the
Creati/e Co&&ons Attri$*tionDNonco&&ercialDShare Ali;e 3"- !nited States Nicense"
0o /ie+ a copy o' this licenseE /isit
httpF::creati/eco&&ons"org:licenses:$yDncDsa:3"-:*s:
or send a letter to
Creati/e Co&&onsE U43 8o+ard StreetE Uth Floor
San FranciscoE Cali'orniaE I4.-UE !SA"
CopyrightDish St*''
139/140
Ed Nisley
Septe&$er .IR,
Say 3N5SSDlee4E altho*gh +e_re on the hal'Dessed $ranch o' the tree
Engineer ?e% PE@E 8ard+are 8ac;erE Progra&&erE A*thor
0he E&$edded PC_s 5SA 9*sF Fir&+areE 2adgetsE Practical 0ric;s

Circ*it Cellar +++"circ*itcellar"co&
Fir&+are F*rnace ?.ITTD.IIR@ D NastyE gr*$$y hard+are $ashing
A$o/e the 2ro*nd Plane ?,--. """@ D Analog and =F st*''
Digital Machinist +++"ho&eshop&achinist"net
Along the 2DCode Way ?,--T """@ D 2DCodeE &athE 3D printing
Dr" Do$$>s Zo*rnal +++"dd6"co&
E&$edded Space ?,--.D,--R@ D All things e&$edded
Nisley>s Note$oo; ?,--RD,--J@ D 8ard+are 7 so't+are collisions
My 9logF 0he S&ell o' Molten Pro6ects in the Morning
so'tsolder"co&
140/140
If you
cant read this
then
make a new friend
way up front

You might also like