Home

OpenSCAD User Manual OpenSCAD User Manual

image

Contents

1. 21 Assign Statement Set variables to a new value for a sub tree Parameters e The variables that should be re assigned Usage example for i 10 50 assign angle i1 360 20 distance 1 10 r i 2 rotate angle 1 0 0 translate 0 distance 0 Sphere r r g Mathematical Operators D The text in its current form is incomplete Scalar Arithmetical Operators The scalar arithmetical operators take numbers as operands and produce a new number add subtract multiply divide modulo The can also be used as prefix operator to negate a number Relational Operators All relational operator take numbers as operands and produce a Boolean value The equal and not equal operators can also compare Boolean values lt less than lt less equal equal not equal gt greater equal gt greater than Logical Operators All logical operators take Boolean values as operands and produce a Boolean value amp amp Logical AND Logical OR Logical NOT 28 Conditional Operator The operator can be used to conditionally evaluate one or another expression It works like the operator from the family of C like programming languages Conditional operator Usage Example c a b 4 5 If a equals b then c is set to 4 else c is set to 5 The part a b must be something that evaluates to a boolean value Vector Number Operators The vector n
2. get a vector of 4 numbers seed 42 random vect rands 5 15 4 Seed echo Random Vector random vect Sphere r 5 for i 0 3 rotate 360 i 4 translate 10 random vect i 0 0 sphere r random vect i 2 round The round operator returns the greatest or least integer part respectively if the numeric input is positive or negative Some examples round x 5 x l round x 49 x round x 5 x l1 round x 49 x round 5 4 gt 5 round 5 5 gt 6 round 5 6 gt 6 36 sign Mathematical signum function Returns a unit value that extracts the Signum function Parameters lt X gt Decimal Value to find the sign of Usage examples sign 5 0 sign 0 sign 8 0 Results 1 0 0 0 1 0 sqrt Mathematical square root function Usage Examples translate sgqrt 100 0 0 sphere 100 o String Functions D The text in its current form is incomplete str Convert all arguments to strings and concatenate Usage examples number 2 echo This is number 3 and that s it echo str This is number 3 and that s it Results ECHO This is 2 3 and that s it ECHO This is 23 and that s it Also See search search for text searching 37 sign of a value see g Transformations Transformation affect the child nodes and as the name implies transforms them in various ways such as moving rotating or scaling the
3. intersection Creates the intersection of all child nodes This keeps the overlapping portion Usage example intersection cylinder h 4 r 1 center true fn 100 rotate 90 0 0 cylinder h 4 r 0 9 center true fn 100 render Always calculate the CSG model for this tree even in OpenCSG preview mode The convexity parameter specifies the maximum number of front sides back sides a ray intersecting the 49 object might penetrate This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering Usage example render convexity 1 m Modifier Characters Modifier characters are used to change the appearance or behaviours of child nodes They are particularly useful in debugging where they can be used to highlight specific objects or include or exclude them from rendering Advanced concept As OpenSCAD uses different libraries to implement capabilities this can introduce some inconsistencies to the F5 preview behaviour of transformations Traditional transforms translate rotate scale mirror amp multimatrix are performed using OpenGL in preview while other more advanced transforms such as resize perform a CGAL operation behaving like a CSG operation affecting the underlying object not just transforming it In particular this can affect the display of modifier characters specifically and where the highlight
4. max lt valuel gt lt value2 gt sqrt lt value gt round lt value gt ceil lt value gt floor lt value gt Lookup lt in value gt lt vector of vectors gt String Functions Str string value Primitive Solids Ccube size lt value or vector gt center lt boolean gt Sphere r lt radius gt cylinder h lt height gt rl lt bottomRadius gt r2 lt topRadius gt center lt boolean gt cylinder h lt height gt r lt radius gt polyhedron points x y z triangles pl p2 p3 convexity N 117 Transformations scale v x y z In versions gt 2013 03 resize newsize x y Z auto true false resize newsize x y Z auto xax1is yaxis zaxis axis is true false resize x y z xax1S yax1s zax1is resize x y z rotate a deg v x y z rotate a x deg y deg z deg translate v x y z mirror 0 1 0 4 3 multmatrix m tranformationMatrix color r g b al color R 255 G 255 B 255 a color blue a Conditional and Iterator Functions for lt loop variable name gt lt vector gt intersection for lt loop variable name gt lt vector of vectors gt if lt boolean condition gt else assign lt varl gt lt vall gt lt var2 gt lt val2
5. lt degrees gt Decimal Angle in degrees Usage example for i 0 5 echo 360 i 6 tan 360 i 6 80 30 translate tan 360 i 6 80 0 O cylinder h 200 r 10 acos Mathematical arccosine or inverse cosine expressed in degrees See Inverse trigonometric functions asin Mathematical arcsine or inverse sine expressed in degrees See Inverse trigonometric functions atan Mathematical arctangent or inverse tangent function Returns the principal value of the arc tangent of x expressed in degrees See Inverse trigonometric functions atan2 Mathematical two argument atan function taking y as its first argument Returns the principal value of the arc tangent of y x expressed in degrees See atan2 Other Mathematical Functions abs Mathematical absolute value function Returns the positive value of a signed decimal number Usage examples abs 5 0 abs 0 abs 8 0 Results 5 0 0 0 8 0 ceil Mathematical ceiling function ceil x is the smallest integer not less than x See Ceil Function echo ceil 4 4 ceil 4 4 produces ECHO 5 4 31 exp Mathematical exp function Returns the base e exponential function of x which is the number e raised to the power x See Exponent floor Mathematical floor function floor x is the largest integer not greater than x See Floor Function echo floor 4 4 floor 4 4 produces ECHO 4 5 In Mathematical natural
6. for xpos 0 3 ypos 2 4 6 do twelve iterations using each xpos with each ypos translate xpos ypos ypos 0 cube 0 5 0 5 0 5 Intersection For Loop Iterate over the values in a vector or range and take an intersection of the contents Note intersection for is a work around because of an issue that you cannot get the expected results using a combination of the standard for and intersection statements The reason is that for do a implicit union of the contents Parameters lt loop variable name gt Name of the variable to use within the for loop Usage example 1 loop over a range 26 intersection for n 1 6 rotate 0 0 n 60 translate 5 0 0 Sphere r 12 b OpenSCAD Intersection for Usage example 2 rotation intersection for i 0 0 0 10 20 300 200 40 57 20 88 57 rotate 1 cube 100 20 20 center true EJ OpenSCAD Intersection for rotation If Statement Conditionally evaluate a sub tree Parameters e The boolean expression that should be used as condition NOTE Do not confuse the assignment operator with the equal operator if a b dosomething WRONG this will FAIL to be processed without any error message if a b dosomething CORRECT this will do something if a equals b Usage example if x gt y cube size 1 center false else cube size 2 center true
7. cylinder h my h r my r echo lt b gt Hello lt b gt lt i gt Qt lt i gt Shows in the Console as ECHO Hello Qt a7 Render Forces the generation of a mesh even in preview mode Useful when the boolean operations become too slow to track Needs description Usage examples render convexity 2 difference cube 20 20 150 center true translate 10 10 0 cylinder h 80 r 10 center true translate 10 10 40 Sphere r 10 translate 10 10 40 Sphere r 10 Surface Example 1 surface scad surface file surface dat center true convexity 5 translate 0 0 5 cube 10 10 10 center true surface dat 109987655555 9876643210 8766432100 7664321000 6643211000 6632111000 6621311431000 661000000 0 3100000000 300000000 0 Result 60 Example 2 example010 dat generated using octave d sin 1 0 2 10 cos 1 0 2 10 10 save example010 dat d intersection surface file example010 dat center true convexity 5 rotate 45 0 0 1 surface file example010 dat center 61 true convexity 5 Search The search function is a general purpose function to find one or more or all occurrences of a value or list of values in a vector string or more complex list of list construct Search Usage search match value string or vector num returns per match index col num Se
8. echo v 1 echo v 1 0 v 1 1 echo search p v echo search p v 0 echo search 9 v 0 1 echo v search 9 v 0 1 0 echo v search 9 v 0 1 0 0 echo v search 9 v 0 1 0 1 echo v search p v 1 0 0 1 echo v search p v 1 0 0 0 echo v search d v 1 0 0 0 echo v search D v 1 0 01 1 r OpenSCAD Version gt 0 2 gt p 3 S p 53 find p gt 1 gt 1 find 9 gt 2 gt e 9 gt eu gt 9 gt 3 gt Li a d not found gt undef gt 8 version and version num will return OpenSCAD version number e The version function will return the OpenSCAD version as a vector e g 23 12011 09 e The version num function will return the OpenSCAD version as a number e g 20110923 64 OpenSCAD User Manual Using the 2D Subsystem lt OpenSCAD User Manual This page may need to be reviewed for quality Using the 2D Subsystem Contents e Using the 2D Subsystem e ll 2D Primitives e 1 1 1 square e 1 1 2 circle e 1 1 3 polygon e 1 1 4 import dxf tee 3D to 2D Projection 1 0 420 to 3D Extrusion e 1 3 1 Linear Extrude e 1 3 1 1 Usage Lecaiae Twist e 1 3 1 3 Center 1 3 1 4 Mesh Refinement e 1 3 1 5 Scale e 1 3 2 Rotate Extrude e 1 3 2 1 Examples e 1 3 2 2 Mesh Refinement e 1 3 2 3 Extruding a Polygon e 1 3 3 Description of extrude parameters e 1 3 3 1 Extrude parameters for all extrusion mod
9. 60 10 60 10 10 50 10 10 50 10 10 30 10 10 30 30 10 50 30 10 50 l triangles 0 2 3 0 1 2 0 4 5 0 5 1 5 4 2 2 4 3 6 8 9 6 7 8 6 10 11 6 11 7 10 8 11 10 9 8 0 3 9 9 0 6 10 6 0 0 4 10 3 9 10 3 10 4 1 7 11 1 11 5 1 7 8 1 8 2 2 8 11 2 11 5 Polyhedron with badly oriented polygons A correct polyhedron would be the following polyhedron points 0 10 60 0 10 60 0 10 0 0 10 0 60 10 60 60 10 60 10 10 50 10 10 50 10 10 30 10 10 30 30 10 50 30 10 50 I triangles 0 3 2 0 2 1 4 0 5 5 0 1 5 2 4 4 2 3 6 8 9 6 7 8 6 10 11 6 11 7 10 8 11 10 9 8 3 0 9 9 0 6 10 6 0 0 4 10 3 9 10 3 10 4 1 7 11 1 11 5 1 8 7 18 2 8 1 8 2 11 5 11 2 Beginner s tip If you don t really understand orientation try to identify the mis oriented pink triangles and then permute the references to the points vectors until you get it right E g in the above example the third triangle 0 4 5 was wrong and we fixed it as 4 0 5 In addition you may select Show Edges from the View Menu print a screen capture and number both the points and the triangles In our example the points are annotated in black and the triangles in blue Turn the object around and make a second copy from the back if needed Th
10. Code Generation e Make sure Runtime Library is set to Multi threaded MT e Glick hit Ok e Close Visual Express saving changes Build OpenCSG library You can use the GUI Build Build menu the Examples project might fail but glew and OpenCSG should succeed Alternatively you can use the command line cmd c vcexpress OpenCSG sln build Again substitute devenv if you have the full visual studio The cmd c bit is needed otherwise you will be returned to the shell immediately and have to Wait for build process to complete there will be no indication that this is happening appart from in task manager OpenSCAD e Bison Flex Open the mingw shell and type mingw get install msys bison Then do the same for flex mingw get install msys flex e Open the QT Shell and copy paste the following commands cd C openscad set INCLUDE INCLUDE C CGAL 3 7 include C CGAL 3 7 auxiliary gmp include set INCLUDE INCLUDE C boost 1 46 1 C glew 1 5 8 include C OpenCSG 1 3 2 include C eigen2 set LIB LIB C CGAL 3 7 lib C CGAL 3 7 auxiliary gmp lib set LIB LIB C boost 1 46 1 lib C glew 1 5 8 lib C OpenCSG 1 3 2 lib qmake nmake f Makefile Release Wait for the nmake to end There are usually a lot of non fatal warnings about the linker On success there will be an openscad exe file in the release folder Enjoy Building an installer e Download and install NSIS from http nsis sourceforge net Download e Put the FileAssocia
11. Example 6 below Search on different column return Index values Example 5 search 3 a 1 b 2 c 3 d 4 a 5 b 6 c 7 d 8 e 3 l Returns 2 8 Search on list of values Example 6 Return all matches per search vector element search abc ie a a E D2 isi C asia a ely a a olel TD Oly Coa ele OG pola eo l 0 Returns 0 4 1 5 2 6 Example 7 Return first match per search vector element special case return vector search abc a 1 b 2 c 3 d 4 a 5 b 6 c 7 d 8 e 9 13 63 Returns 0 1 2 Example 8 Return first two matches per search vector element vector of vectors search abce 2 Returns 10 4 1 5 2 6 8 Search on list of strings Example 9 a 1 1 b 21 c 31 d 4 a 5 b 6 c 7 d 8 e 9 J lTable2 cat 1 b 2 c 3 dog 4 a 5 b 6 c 7 d 8 e 9 apple 10 a 11 LSearch2 b BFTF a aay aa P apple i dog l2 search lSearch2 lTable2 echo str Default list string search lSearch2 Returns ECHO bes Elin Ag 25 94 3 Getting the right results workout which vectors get the results l2 Default list string search b zzz a c apple dog v 0 2 p 3 0 e 9 0 4 0 5 5 0 C 6 A 71 D 8 J echo v 0
12. Inkscape to OpenSCAD are available here blogspot com 2011 05 inkscape to openscad dxf tutorial html Very e http tonybuser com tag inkscape More complicated involves conversion to Postscript e http www damonkohler com 2010 11 inkscape dxf openscad makerbot html Better Better DXF Plugin for Inkscape Description of extrude parameters Extrude parameters for all extrusion modes scale FIXME convexity See 2D to 3D Extrusion file The name of the DXF file to extrude DEPRECATED layer The name of the DXF layer to extrude DEPRECATED E x y coordinates to use as the drawing s center in the units specified in the DXF file DEPRECATED Extrude parameters for linear extrusion only height The extrusion height center If true extrusion is half up and half down If false the section is extruded up twist The extrusion twist in degrees slices FIXME OpenSCAD User Manual STL Import and Export lt OpenSCAD User Manual This page may need to be reviewed for quality Import and Export A prime ingredient of any 3D design flow is the ability to import from and export to other tools The SIL file format is currently the most common format used 80 o Import D The text in its current form is incomplete import Imports a file for use in the current OpenSCAD model Parameters lt file gt A string containing the path to the SIL or DXF file Usage examples import example012 stl Notes
13. double fn double fs double fa if r lt GRID FINE return 3 if fn gt 0 0 return int fn gt 3 fn 3 return int ceil fmax fmin 360 0 fa r 2 M PI fs 5 Spheres are first sliced into as many slices as the number of fragments being used to render a circle of the sphere s radius and then every slice is rendered into as many fragments as are needed for the slice radius You might have recognized already that the pole of a sphere is usually a pentagon This is why The number of fragments for a cylinder is determined using the greater of the two radii The method is also used when rendering circles and arcs from DXF files You can generate high resolution spheres by resetting the fX values in the instantiating module S fs 0 01 Sphere 2 or simply by passing the special variable as parameter sphere 2 fs 0 01 You can even scale the special variable instead of resetting it Sphere 2 fs fs 0 01 St The t variable is used for animation If you enable the animation frame with view gt animate and give a value for FPS and Steps the Time field shows the current value of t With this information in mind you can animate your design The design is recompiled every 1 FPS seconds with t incremented by 1 Steps for Steps times ending at either t 1 or t 1 l1 steps If Dump Pictures is checked then images will be created in the same directory as the scad file usin
14. scale 0 5 1 2 cube 10 38 resize resize is available since OpenSCAD 2013 06 It modifies the size of the child object to match the given x y and z There is a bug with shrinking in the 2013 06 release that will be fixed in the next release Usage Example resize the sphere to extend 30 in x 60 in y and 10 in the z directions resize newsize 30 60 10 sphere r 10 39 resize newsize 30 60 10 sphere r 10 If x y or z is O then that dimension is left as is resize the 1x1x1 cube to 2x2x1 resize 2 2 0 cube If the auto parameter is set to true it will auto scale any O dimensions to match For example resize the 1x2x0 5 cube to 7x14x3 5 resize 7 0 0 auto true cube 1 2 0 5 The auto parameter can also be used if you only wish to auto scale a single dimension and leave the other as is resize to 10x8x1 Note that the z dimension is left alone resize 10 0 0 auto true true false cube 5 4 1 rotate Rotates its child a degrees about the origin of the coordinate system or around an arbitrary axis The argument names are optional if the arguments are given in the same order as specified above When a rotation is specified for multiple axes then the rotation is applied in the following order x y Z Usage rotate a deg v x y z For example to flip an object upside down you might do this rotate a 0 180 0 The above
15. something using both variables gt for loops can be nested just as in normal programs A shorthand is that both iterations can be given in the same for statement 24 Usage example 1 iteration over a vector for z 1 1 two iterations z 1 z 1 translate 0 0 z cube size 1 center false OpenSCAD iteration over a vector Usage example 2a iteration over a range for i 0 5 rotate i 360 6 1 0 0 translate 0 10 0 Sphere r 1 BA OpenSCAD iteration over a range Usage example 2b iteration over a range specifying an increment Note The middle parameter in the range designation 0 2 in this case is the increment by value Warning Depending on the increment by value the real end value may be smaller than the given one for i 0 0 2 5 rotate i 360 6 1 0 0 translate 0 10 0 Sphere r 1 Usage example 3 iteration over a vector of vectors rotation ZO for i 0 0 0l 10 20 300 200 40 57 20 88 57 rotate i cube 100 20 20 center true h OpenSCAD for loop rotation Usage example 4 iteration over a vector of vectors translation for i 0 0 0 10 12 10 20 24 20 30 36 30 20 48 40 10 60 50 translate i cube 50 15 10 center true i OpenSCAD for loop translation Nested loop example
16. 255 you can use As of the 2011 12 version colors can also be chosen by name name is not case sensitive For example to create a red sphere you can use this code color red sphere 5 Alpha is also available with named colors color Blue 0 5 cube 5 The available color names are taken from the World Wide Web consortium s SVG color list A chart of the color names is as follows slategrey slategray etc are valid Purples Lavender ihe tre um DarkGreen Pinks Pink LightPink 44 Greens Yellows LightYellow LemonChiffon LightGoldenrodYellow PapayaWhip Moccasin PeachPuff PaleGoldenrod Browns Cornsilk BlanchedAlmond Bisque NavajoWhite Wheat note that both spelling of grey gray including Whites White Snow Honeydew MintCream Azure AliceBlue GhostWhite WhiteSmoke Seashell Beige OldLace FloralWhite Ivory AntiqueWhite Linen LavenderBlush MistyRose Grays Gainsboro LightGrey Silver DarkGray Blues LightCyan PaleTurquoise LightSteelBlue PowderBlue LightBlue MidnightBlue Reds DarkRed 45 Oranges Maroon BA A 3 D multicolor sine wave Here s a code fragment that draws a wavy multicolor object for i 0 36 for j 0 36 color 0 5 sin 10 i 2 0 5 sin 10 j 2 0 5 sin 10 i j 2 translate 1 j 0 cube size 1 1 11 10 cos 10 1 sin 10 j Being that l lt sin x lt 1 then 0 lt 1 2
17. In the latest version of OpenSCAD import is now used for importing both 2D DXF for extrusion and 3D STL files import_stl lt DEPRECATED Use the command import instead gt Imports an SIL file for use in the current OpenSCAD model Parameters lt file gt A string containing the path to the STL file to include lt convexity gt Integer The convexity parameter specifies the maximum number of front sides back sides a ray intersecting the object might penetrate This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering Usage examples import stl example012 stl convexity 5 go STL Export D The text in its current form is incomplete STL Export To export your design select Export as SIL from the Design menu then enter a filename in the ensuing dialog box Don t forget to add the stl extension Trouble shooting After compile and render GCAL F6 you may see that your design is simple no That s bad news See line 8 in the following output from OpenSCAD 2010 02 81 Parsing design AST generation Compiling design CSG Tree generation Compilation finished Rendering Polygon Mesh using CGAL Number of vertices currently in CGAL cache 732 Number of objects currently in CGAL cache 12 Top level object is a 3D object Simple no eK KOK K K K FK FK FK K FK K K FK K K Valid yes Vertices 22 Half
18. Sfs 14 Fragment size in mm Sfn Resolution Usage Examples Sphere r 1 Ssphere r 5 Sphere r 10 Sphere d 2 sphere d 10 Sphere d 20 this will create a high resolution sphere with a 2mm radius Sphere 2 fn 100 will also create a 2mm high resolution sphere but this one does not have as many small triangles on the poles of the sphere Sphere 2 fa 5 fs 0 1 here 10 sphere r 1 sear sphere r 5 cylinder Creates a cylinder or cone at the origin of the coordinate system A single radius r makes a cylinder two different radi rl r2 make a cone Parameters h Decimal This is the height of the cylinder Default value is l f Decimal The radius of both top and bottom ends of the cylinder Use this parameter if you want plain cylinder Default value is l rl Decimal This is the radius of the cone on bottom end Default value is 1 ro Decimal This is the radius of the cone on top end Default value is 1 d Decimal The diameter of both top and bottom ends of the cylinder Use this parameter if you want plain cylinder Default value is 1 LS dl Decimal This is the diameter of the cone on bottom end Default value is l d2 Decimal This is the diameter of the cone on top end Default value is 1 center boolean If true will center the height of the cone cylinder around the origin Default is false placing the base of the cylinder or rl radius of cone at the ori
19. also read and create 3D models in the STL and OFF file formats OpenSCAD can be downloaded from http openscad org You may find extra information in the mailing list People who don t want to or can t install new software on their computer may be able to use OpenJSCAD http OpenJSCAD org a port of OpenSCAD that runs in a web browser A pt_BR translation of this document is avaliable on GitHub repository not completed on development 1 First Steps Overview A printable version of OpenSCAD User Manual is available edit it 1 El Introduction fal First Steps fol The OpenSCAD User Interface E The OpenSCAD Language Primitive Solids cube sphere cylinder amp polyhedron General comments variables amp input dxf dimQ Mathematical Operators Mathematical Functions 1 Trigonometric cos sin tan acos asin atan atan2 2 Other abs ceil exp floor 1n len log lookup max min norm pow rands round sign sqrt otring Functions str 6 Transformations Size amp placement scale resize rotate translate mirror multmatrix color minkowski amp hull 7 Conditional and Iterator Functions for if amp assign 8 CSG Modelling Combine primitives union difference intersection amp render 9 Modifier Characters Debugging aids 10 Modules Write your own primitive transformation function 11 Include Statement 12 O0ther Language Features Special variables user defined functions ec
20. and functions but does not execute any commands other than those definitions Library files are searched for in the same folder as the design was open from or in the library folder of the OpenSCAD installation You can use a relative path specification to either I they lie elsewhere you must give the complete path Newer versions have predefined user libraries see the OpenSCAD User Manual Libraries page which also documents a number of library files included in OpenSCAD Windows and Linux Mac use different separators for directories Windows uses e g directory file ext while the others use e g directory file ext This could lead to cross platform issues However OpenSCAD on Windows correctly handles the use of so using in all include or use statements will work on all platforms Using include lt filename gt allows default variables to be specified in the library These defaults can be overridden in the main code An openscad variable only has one value during the life of the program When there are multiple assignments it takes the last value but assigns when the variable is first created This has an effect when assigning in a library as any variables which you later use to change the default must be assigned before the include statement See the second example below A library file for generating rings might look like this defining a function and providing an example ring scad module ring rl r2 h differe
21. child Cascading transformations are used to apply a variety of transforms to a final child Cascading is achieved by nesting statements i e transform e g rotate 45 45 45 transform translate 10 20 30 child cube 10 Note child is deprecated by children in master 2013 06 still uses child Transformations can be applied to a group of child nodes by using amp to enclose the subtree e g translate 0 0 5 or the more compact translate 0 0 5 cube 10 cube 10 cylinder r 5 h 10 cylinder r 5 h 10 Advanced concept As OpenSCAD uses different libraries to implement capabilities this can introduce some inconsistencies to the F5 preview behaviour of transformations Traditional transforms translate rotate scale mirror amp multimatrix are performed using OpenGL in preview while other more advanced transforms such as resize perform a CGAL operation behaving like a CSG operation affecting the underlying object not just transforming it In particular this can affect the display of modifier characters specifically and where the highlight may not display intuitively such as highlighting the pre resized object but highlighting the post scaled object D The text in its current form is incomplete scale Scales its child elements using the specified vector The argument name is optional Usage Example scale v x y z cube 10 translate 15 0 0
22. eigen2 e C glew 1 5 8 e C OpenCSG 1 3 2 tgz can be extracted with tar zxvf from the MingW shell or Windows tools like 7 zip Rename and move sub directories if needed I e eigen eigen O938af7840b0 should become c eigen2 with the files like COPYING and CMakeLists txt directly under it c glew 1 5 8 should have include and lib directly under it Compiling Dependencies For compilation I use the QT Development Command Prompt Start gt Program Files gt Qt by Nokia v4 7 2 VS2008 OpenSource gt QT 4 7 2 Command Prompt Qt Qt needs to be recompiled to get a static C runtime build To do so open the command prompt and do configure static platform win32 msvc2008 no webkit Configure will take several minutes to finish processing After it is done open up the file Qt 4 7 2 mkspecs win32 msvc2008 qmake conf and replace every instance of MD with MT Then nmake This takes a very very long time Have a nap Get something to eat On a Pentium 4 2 8GHZ 107 CPU with 1 Gigabyte RAM Windows XP it took more than 7 hours that was with 02 turned off CGAL cd C CGAL 3 7 set BOOST ROOT C boost 1 46 1 cmake Now edit the CMakeCache txt file Replace every instance of MD with MT Now look for a line like this CMAKE BUILD TYPE STRING Debug Change Debug to Release Now re run cmake cmake It should scroll by watch for lines saying Building static libraries and Build type Releas
23. example will rotate your object 180 degrees around the y axis The optional argument v allows you to set an arbitrary axis about which the object will be rotated 40 Example with arbitrary origin rotate a 45 v 1 1 0 This example will rotate your object 45 degrees around the axis defined by the vector 1 1 0 i e 45 around X and 45 around Y If this is all a bit confusing this might or might not help For the case of rotate a b c a is a rotation about the X axis from the Z axis toward the Y axis NOTE NEGATIVE Y b is a rotation about the Y axis from the Z axis toward the X axis c is a rotation about the Z axis from the X axis toward the Y axis Thus if a is fixed to zero and b and c are manipulated appropriately this is the spherical coordinate system So to construct a cylinder from the origin to some other point x y z Length sqrt pow x 2 pow y 2 pow z 2 b acos z length c x 0 90 x gt 0 atan y x atan y x 180 rotate 0 b c cylinder h length r 0 5 translate Translates moves its child elements along the specified vector The argument name is optional IExample translate v x y z cube 2 center true translate 5 0 0 Sphere 1 center true A cube 2 center true translate 5 0 0 sphere 1 center true mirror Mirrors the child element on a plane through the origin The ar
24. first model we will create a simple 2 x 3 x 4 cuboid In the openSCAD editor type the following one line command Usage example 1 simple cuboid cube 2 3 4 OpenSCAD Simple Cuboid Compiling and rendering our first model The cuboid can now be compiled and rendered by pressing F6 while the openSCAD editor has focus See also Positioning an object OpenSCAD User Manual First Steps Opening an existing example model lt OpenSCAD User Manual First Steps eS eee ee ee ee ee ee as psa eee a j i i ei amaa E mm OpenSCAD after starting Open one of the many examples that come with OpenSCAD File Examples e g example004 scad Or you can copy and paste this simple example into the OpenSCAD window Usage example 1 example004 scad difference cube 30 center true cube LIO centerstrutl sphere 20 translatelto 201 i cylinder haa r bOb translate 0 0 30 cylinder h 40 r 10 a a OpenSCAD after pasting the example code and pressing F5 Then press F5 to get a graphical preview of what you typed You get three types of movement in the preview frame l Drag with left mouse button to rotate the view The bottom line will change the rotate values 2 Drag with an other mouse button to translate move the view The bottom line will change translate values 3 Use the mouse scroll to zoom in and out Alternatively you can use the and keys or right drag with
25. import Q instead Read a DXF file and create a 2D shape Example linear _extrude height 5 center true convexity 10 import dxf file example009 dxf layer plate o 3D to 2D Projection Using the projection function you can create 2d drawings from 3d models and export them to the dxf format It works by projecting a 3D model to the x y plane with z at O If cut true only points with z 0 will be considered effectively cutting the object with cut false points above and below the plane will be considered as well creating a proper projection Example Consider example002 scad that comes with OpenSCAD A Then you can do a cut projection which gives you the slice of the x y plane with z 0 projection cut true example002 68 gt g A You can also do an ordinary projection which gives a sort of shadow of the object onto the xy plane projection cut false example002 JA ad Another Example You can also use projection to get a side view of an object Let s take example002 and move it up out of the X Y plane and rotate it translate 0 0 25 rotate 90 0 0 example002 an Now we can get a side view with projection projection translate 0 0 25 rotate 90 0 0 example002 A Links e exampleO21 scad from Clifford Wolf s site e More complicated example from Giles Bathgate s blog ga 2D to 3D Extr
26. logarithm See Natural logarithm len Mathematical length function Returns the length of an array a vector or a string parameter Usage examples Strl abcdef len strl len str1 echo stri1 len str1 a 6 len a Len a echo a len a arrayl 1 2 3 4 5 6 7 8 len arrayl Llen arrayl1 echo arrayl len arrayl1 array2 0 0 0 1 1 0 1 1 len array2 lLen array2 echo array2 len array2 len_array2 2 Len array2 2 echo array2 2 len array2 2 Results ECHO abcdef 6 ECHO 6 undef ECHO 1 2 3 4 5 6 7 8 8 ECHO 0 0 90 1 1 0 1 lll 4 ECHO 1 0 2 This function allows e g the parsing of an array a vector or a string Usage examples str2 4711 for 1 0 len str2 1 echo str digit i 1 str2 i Results ECHO digit 1 4 ECHO digit 2 7 32 ECHO digit 3 1 ECHO digit 4 1 Note that the len Q function is not defined when a simple variable is passed as the parameter This is useful when handling parameters to a module similar to how shapes can be defined as a single number or as an x y z vector i e cube 5 or cube 5 5 5 For example module doIt size if len size undef size is a number use it for x y amp z or could be undef do size size size else size is a vector could be a string but that would be stupid do size doIt 5 equivalent to 5 5 5 doIt 5 5 5 s
27. may not display intuitively such as highlighting the pre resized object but highlighting the post scaled object D The text in its current form is incomplete Note The color changes triggered by character modifiers will only be shown in Compile mode not Compile and Render CGAL mode As per the color section Background Modifier Ignore this subtree for the normal rendering process and draw it in transparent gray all transformations are still applied to the nodes in this tree Usage example Example code difference start objects cylinder h 4 r 1 center true fn 100 first object that will subtracted rotate 90 0 0 cylinder h 4 r 0 3 center second object that will be subtracted rotate 0 90 0 cylinder h 4 r 0 9 center true fn 100 true fn 100 50 rs Background modifier example Debug Modifier Use this subtree as usual in the rendering process but also draw it unmodified in transparent pink Usage example 44 Example difference start objects cylinder h 4 r 1 center true fn 100 first object that will subtracted rotate 90 0 0 cylinder h 4 r 0 3 center true fn 100 second object that will be subtracted rotate 0 90 0 cylinder h 4 r 0 9 center true fn 100 OpenScad Debug Modifier example Root Modifier Ignore the rest of the design and use this subtree as
28. newer The names are the same used for Web colors For example color red cube If you think of the entire command as a sentence then color is an adjective that describes the object of the sentence which is a noun In this case the object is the Cube to be created The adjective is placed before the noun in the sentence like so color cube In the same way translate can be thought of as a verb that acts upon the object and is placed like this translate color cube The following code will produce the same result translate 6 0 0 color 0 0 1 notice that there is NO semicolon cube 2 3 4 notice the semicolon is at the end of all related commands j Changing the colors only works in Preview mode F5 Render mode F6 does not currently support color Category e OpenSCAD User Manual OpenSCAD User Manual First Steps Model views lt OpenSCAD User Manual First Steps The latest reviewed version was checked on 23 June 2013 There are 2 pending changes awaiting review D The text in its current form is incomplete The openscad model view window provides a variety of view options Contents e CGAL Surfaces e 2 CGAL Grid Only e 3 The OpenCSG View e 4 The thrown together view CGAL Surfaces The surface view is the initial model view that appears when the model code is first rendered CGAL Grid Only The Grid Only view presents only the scaffolding beneath th
29. not support OpenGL then this view will produce no visible output The thrown together view The thrown together view provides all the previous views in the same screen OpenSCAD User Manual The OpenSCAD User Interface lt OpenSCAD User Manual This page may need to be reviewed for quality Contents e View navigation e 2 View setup e 2 1 Render modes e 2 1 1 OpenCSG F9 e 2 1 1 1 Implementation Details e 2 1 2 CGAL Surfaces and Grid F10 and F11 e 2 1 2 1 Implementation Details e 2 2 View options e 2 2 1 Show Edges Ctrl l e 2 2 2 Show Axes Ctrlt 2 e 2 2 3 Show Crosshairs Ctr1 3 e 2 3 Animation e 2 4 View alignment View navigation The viewing area is navigated primarily using the mouse e Dragging with the left mouse button rotates the view along the axes of the viewing area It preserves the vertical axis direction e Dragging with the left mouse button when the shift key is pressed rotates the view along the vertical axis and the axis pointing towards the user e Dragging with the right mouse button moves the viewing area e For zooming there are four ways e using the scroll wheel e dragging with the middle mouse button e dragging with the right or middle mouse button and the shift key pressed e the keys and Rotation can be reset using the shortcut Ctr1 0O Movement can be reset using the shortcut Cirricke View setup The viewing area can be configured to use different renderi
30. output uses Preview mode 5 with OpenCSG For some situations it will be desirable instead to use the full render with CGAL This is done by adding render as an option Constants In order to pre define variables use the D option It can be given repeatedly Each occurrence of D must be followed by an assignment Unlike normal OpenSCAD assignments these assignments don t define variables but constants which can not be changed inside the program and can thus be used to overwrite values defined in the program at export time If you want to assign the D variable to anther variable the D variable MUST be initialised in the main scad program paraml1 0 must be initalised len param1 paraml passed via D on cmd line echo len param without the first line len wound be undefined The right hand sides can be arbitrary OpenSCAD expressions including mathematical operations and strings Be aware that strings have to be enclosed in quotes which have to 89 be escaped from the shell To render a model that takes a quality parameter with the value production one has to run Openscad o my model production stl D quality production my model scad Command to build required files In a complex build process some files required by an OpenSCAD file might be currently missing but can be generated for example if they are defined in a Makefile If OpenSCAD is siven the option m make it will start make file the first
31. prefer not to install you can run openscad directly whilst still in the openscad directory Compiling the test suite OpenSCAD comes with over 740 regression tests To build and run them it is recommended to first build the GUI version of OpenSCAD by following the steps above including the downloading of MCAD Then from the same login run these commands cd tests mkdir build amp amp cd build cmake make ctest C ALL The file openscad doc testing txt has more information Full test logs are under tests build Testing Temporary A pretty printed index html web view of the tests can be found under a machine specific subdirectory thereof and opened with a browser Troubleshooting If you encounter any errors when building please file an issue report at https github com openscad openscad issues Errors about incompatible library versions This may be caused by old libraries living in usr local lib like boost CGAL OpenCSG etc often left over from previous experiments with OpenSCAD You are advised to remove them To remove for example CGAL run rm rf usr local include CGAL amp amp rm rf usr local 1lib CGAL Then erase HOME openscad deps remove your openscad source tree and 99 restart fresh As of 2013 OpenSCAD s build process does not advise nor require anything to be installed in usr local lib nor usr local include Note that CGAL depends on Boost and OpenCSG depends on GLEW interdependenci
32. scad files with deps make make re build always keeping the scad files solves this problem explanations are welcome SECONDARY shell echo TARGETS sed s stl scad g explicit wildcard expansion suppresses errors when no files are found include wildcard deps SCad echo n use lt base scad gt n gt 90 stl Scad openscad m make o d deps lt All objects that are supposed to be exported automatically have to be defined in base scad in an own module with their future file name without the stl and have a comment like make me in the line of the module definition The TARGETS line picks these out of the base file and creates the file names These will be built when make all or make for short is called As the convention from the last example is to create the stl files from scad files of the same base name for each of these files an scad file has to be generated This is done in the scad paragraph my example scad will be a very simple OpenSCAD file use lt base scad gt my example The SECONDARY line is there to keep make from deleting the generated scad files If it deleted it it would not be able to automatically determine which files need no rebuild any more please post ideas about what exactly goes wrong there or how to fix it better on the talk page Windows notes On Windows openscad com should be called from the command line as a wra
33. sin x 2 lt 1 allowing for the RGB components assigned to color to remain within the 0 1 interval Chart based on Web Colors from Wikipedia minkowski EJ A box and a cylinder E Minkowski sum of the box and cylinder Displays the minkowski sum of child nodes 46 Usage example Say you have a flat box and you want a rounded edge There are many ways to do this but minkowski is very elegant Take your box and a cylinder fn 50 cube 10 10 1 cylinder r 2 h 1 Then do a minkowski sum of them fn 50 minkowski cube 10 10 1 cylinder r 2 h 1 hull Two cylinders Convex hull of two cylinders Displays the convex hull of child nodes Usage example hull translate 15 10 0 circle 10 circle 10 a CSG Modelin The text in its current form is incomplete 4T union Creates a union of all its child nodes This is the sum of all children Usage example union cylinder h 4 r 1 center true fn 100 rotate 90 0 0 cylinder h 4 r 0 9 center true fn 100 Remark union is implicit when not used But it is mandatory for example in difference to group first child nodes into one difference Subtracts the 2nd and all further child nodes from the first one Usage example difference cylinder h 4 r 1 center true fn 100 rotate 90 0 0 cylinder h 4 r 0 9 center true fn 100 48
34. the CGAL geometry library OpenCSG uses special tricks of OpenGL graphics cards to quickly produce 2 d previews of Computational Solid Geometry operations This is the normal F5 mode CGAL on the other hand is a Geometry library that actually calculates intersections amp unions of objects allowing for stl export to 3d printers This is the F6 mode In theory though the backend libraries could be replaced OpenSCAD is a text based CAD program It doesn t matter what backend is used for it s geometry as long as it works properly and provides useful functions Discussions on the mailing list have mentioned the possibility of the OpenCASCADE library instead of CGAL for example OpenCSG OpenCSG is based largely around special algorithms that can fake the presentation of Computational Solid Geometry operations subtraction intersection union on a 2d screen The two main algorithms it uses are SCS and Goldfeather selectable in OpenSCAD from the preferences menu The algorithms work by breaking down CSG operations into parts and then rendering the parts into an OpenGL graphics buffer using special features such as an off screen OpenGL Framebuffer Object or Pbuffers as well as making extensive use of the OpenGL Stencil Buffer and Depth Buffer OpenCSG also requires that the objects be normalized For example if your code says to start with a cube subtract a sphere add a diamond add a cylinder add two more spheres an
35. the mouse while pressing a shift key The Viewport line at the bottom of the window will show a change in the distance value OpenSCAD User Manual First Steps Positioning an object lt OpenSCAD User Manual First Steps We have already seen how to create a simple cuboid Our next task is to attempt to use the translate positioning command to place an identical cuboid next to the existing cuboid Usage example 1 positioning an object cube 2 3 4 translate 3 0 0 cube 2 3 4 OpenSCAD positioning an object There is no semicolon following the translate command Notice that there is no semicolon following the translate command This is because the translate command relates to the following object If the semicolon was not omitted then the effect of the position translation would end and the second cuboid would be placed at the same position as the first cuboid OpenSCAD User Manual First Steps Changing the colour of an object lt OpenSCAD User Manual First Steps We can change the color of an object by giving it RGB values Instead of the traditional RGB values from 0 to 255 floating point values are used from 0 0 to 1 0 Usage example 1 changing the color of an object color 1 0 0 cube 2 3 4 translate 3 0 0 color 0 1 0 cube 2 3 4 translate 6 0 0 color 0 0 1 cube 2 3 4 OpenSCAD changing the color of an object Color names can be used in the 2011 12 version and
36. the view will simulate a camera in infinite distance with infinite focal length This is especially useful in combination with the Top etc options described above as this will result in a 2D image Similar to what one would see in an engineering drawing OpenSCAD User Manual The OpenSCAD Language lt OpenSCAD User Manual This page may need to be reviewed for quality The OpenSCAD Language Contents e The OpenSCAD Language e 1 1 Primitive Solids e 1 1 1 cube e 1 1 2 sphere e 1 1 3 cylinder e 1 1 4 polyhedron e 1 2 General e 1 2 1 Comments e 1 2 2 Variables e 1 2 2 1 Undefined variable JaZs2se2 Numeric e 1 2 2 3 Vectors e 1 2 2 3 1 Vectors selection dataeeoae Matrix j 2 2 4 Srrines e 1 2 2 5 Variables are set at compile time not run time e 1 2 2 5 1 Exception 1 e 1 2 2 5 2 Exception 2 e 1 2 3 Getting input e 1 3 Conditional and Iterator Functions dleasd For Loop ll e 1 3 2 Intersection For Loop e 1 3 3 If Statement e 1 3 4 Assign Statement e 1 4 Mathematical Operators e 1 4 1 Scalar Arithmetical Operators e 1 4 2 Relational Operators e 1 4 3 Logical Operators e 1 4 4 Conditional Operator e 1 4 5 Vector Number Operators e 1 4 6 Vector Operators e 1 4 7 Vector Dot Product Operator e 1 4 8 Matrix Multiplication e 1 5 Mathematical Functions e 1 6 Trigonometric Functions e 1 6 1 cos e 1 0 2 sin e 1 6 3 tan e 1 6 4 acos e 1 6 5 asin e 1 6 6 atan e 1 6 7 atan2 e 7 Other Mat
37. try to compile CGAL yourself It is recommended to install to HOME openscad deps and otherwise follow the build process as outlined above Compiling is horribly slow and or grinds the disk It is recommended to have at least 1 2 Gbyte of RAM to compile OpenSCAD There are a few workarounds in case you don t The first is to use the experimental support for the Clang Compiler described below as Clang uses much less RAM than GCC Another workaround is to edit the Makefile generated by qmake and search replace the optimization flags 02 with Ol or blank and to remove any g debug flags from the compiler line as well as pipe 100 If you have plenty of RAM and just want to speed up the build you can try a paralell multicore build with make jx Where x is the number of cores you want to use Remember you need x times the amount of RAM to avoid possible disk thrashing The reason the build is slow is because OpenSCAD uses template libraries like CGAL Boost and Eigen which use large amounts of RAM to compile especially CGAL GCC may take up 1 5 Gigabytes of RAM on some systems during the build of certain CGAL modules There is more information at StackOverflow com BSD issues The build instructions above are designed to work unchanged on FreeBSD and NetBSD However the BSDs typically require special environment variables set up to build any QT project you can set them up automatically by running Source scripts seten
38. useful to read a rotation angle an extrusion height or spacing between parts In the drawing create a dimension that does not show the dimension value but an identifier To read the value you specify this identifier from your script TotalWidth dxf_dim file drawing dxf name TotalWidth Layer SCAD Origin origin 0 0 scale 1 For a nice example of both functions see Example009 and the image on the homepage of OpenSCAD ga Conditional and Iterator Functions For Loop Iterate over the values in a vector or range Vector version for variable lt vector gt lt do_something gt lt variable gt is assigned to each successive value in the vector Range version for variable lt range gt lt do_something gt Range lt start gt lt end gt iterate from start to end inclusive Also works if if lt end gt is smaller than lt start gt Range lt start gt lt increment gt lt end gt iterate from start to end with the given increment The increment can be a fraction Note The increment is given as an absolute value and cannot be negative If lt end gt is smaller than lt start gt the increment should remain unchanged Warning If the increment is not an even divider of lt end gt lt start gt the iterator value for the last iteration will be lt end gt lt end gt lt start gt mod lt increment gt Nested loops for variablel lt range or vector gt variable2 lt range or vector gt lt do
39. 00 translate 2 0 0 circle r 1 Center Center determines if the object is centered after extrusion so it does not extrude up and down from the center as you might expect center true linear extrude height 10 center true convexity 10 twist 500 translate 2 0 0 circle r 1 73 center false linear extrude height 10 center false convexity 10 twist 500 translate 2 0 0 circle r 1 Mesh Refinement The slices parameter can be used to improve the output linear _extrude height 10 center false convexity 10 twist 360 slices 100 translate 2 0 0 circle r 1 74 The special variables fn fs and fa can also be used to improve the output linear extrude height 10 center false convexity 10 twist 360 fn 100 translate 2 0 0 circle r 1 Scale Scales the 2D shape by this value over the height of the extrusion Scale can be a scalar or a vector linear extrude height 10 center true convexity 10 scale 3 translate 2 0 0 circle r 1 linear extrude height 10 center true convexity 10 scale 1 5 fn 100 translate 2 0 0 circle r 1 To Rotate Extrude A rotational extrusion is a Linear Extrusion with a twist literally Unfortunately it can not be used to produce a helix for screw threads as the 2D outline must be normal to the axis of rotation ie they need to be flat in 2
40. D space Examples A simple torus can be constructed using a rotational extrude rotate extrude convexity 10 translate 2 0 0 circle r 1 76 Mesh Refinement Increasing the number of fragments that the 2D shape is composed of will improve the quality of the mesh but take longer to render rotate extrude convexity 10 translate 2 0 0 circle r 1 fn 100 The number of fragments used by the extrusion can also be increased rotate extrude convexity 10 fn 100 translate 2 0 0 circle r 1 fn 100 Extruding a Polygon Extrusion can also be performed on polygons with points chosen by the user Here is a simple polygon Note it has been rotated 90 degrees to show how the rotation will TT look the rotate extrude O needs it flat rotate 90 0 0 polygon points 0 0 2 1 1 2 1 3 3 4 0 5 Here is the same polygon rotationally extruded and with the mesh refinement set to 200 The polygon must touch the rotational axis for the extrusion to work i e you can t build a polygon rotation with a hole rotate extrude fn 200 polygon points 0 0 2 1 1 2 1 3 3 4 0 5 For more information on polygons please see 2D Primitives Polygon Description of extrude parameters Extrude parameters for all extrusion modes Integer The convexity parameter specifies the maximum number of front sides back sides a ray intersecting the object might penetr
41. OpenSCAD User Manual OpenSCAD User Manual il The latest reviewed version was approved on 3 June 2013 There are 6 pending changes awaiting review OpenSCAD is a software for creating solid 3D CAD objects It is free software and available for GNU Linux MS Windows and Apple OS X Unlike most free software for creating 3D models such as the well known application Blender OpenSCAD does not focus on the artistic aspects of 3D modelling but instead focuses on the CAD aspects So it might be the application you are looking for when you are planning to create 3D models of machine parts but probably is not what you are looking for when you are more interested in creating computer animated movies OpenSCAD is not an interactive modeller Instead it is something like a 3D interpreter that reads in a script file that describes the object and renders the 3D model from the script file This gives you the designer full control over the modelling process and enables you to easily change any step in the modelling process or even to produce designs that are defined by configurable parameters OpenSCAD provides two main modelling techniques First constructive solid geometry CSG and second extrusion of 2D outlines Autocad DXF files are used as the data exchange format for the 2D outlines In addition to 2D paths for extrusion it is also possible to read design parameters from DXF files In addition to reading DXF files OpenSCAD can
42. ad http www thingiverse com thing 3575 e gear e bevel gear e bevel gear pair e gears scad Old version e gear number of teeth circular pitch OR diametrical pitch pressure angle OPTIONAL clearance OPTIONAL e motors scad stepper motor mount nema standard slide distance OPTIONAL mochup OPTIONAL Other tools alpha quality e nuts and bolts scad for creating metric and imperial bolt nut holes e bearing scad standard custom bearings e screw cad screws and augers e materials scad color definitions for different materials e math scad general math functions e constants scad mathematical constants e curves scad mathematical functions defining curves e units scad easy metric units e utilities geometric functions and misc useful stuff ISO standard screw threads Metric and inch dimensions ISO standard thread profiles for both external threads bolt and internal threads nut the clearances are slightly different between the two Sprockets for roller chain Sprockets for ANSI chain in various sizes and Motorcycle chain Tested with 25 chain Library has hard coded fudge factors to munge distances to account for printer tolerances you may need to tweak those to your needs OpenSCAD Pinball Parts library A set of pinball parts models for pinball design work Includes models for 3d printing of the parts 3d descriptions of mount holes for CNC drilling and 2d descriptions of parts footpri
43. arch Arguments e match value e num 62 Can be a single value or vector of values Strings are treated as vectors of characters to iterate over the search function does not search for substrings Note If match value is a vector of strings search will look for exact string matches e See Example 9 below e string or_vector The string or vector to search for matches returns per match default 1 By default search only looks for one match per element of match value to return as a list of indices If num returns per_ match gt 1 search returns a list of lists of up to num returns per_match index values for each element of match value e See Example 8 below e If num returns per match 0 search returns a list of lists of all matching index values for each element of match value e See Example 6 below e index_col_ num default 0 e When string _or_vector is a vector of vectors multidimensional table or more complex list of lists construct the match value may not be found in the first index col num 0 column e See Example 5 below for a simple usage example Search Usage Examples See example023 scad included with OpenSCAD for a renderable example Index values return as list Example Code Result 1 search a abcdabcd o 2 search e abcdabcd 3 search a abcdabcd 0 0 4 f search a a 1 b 2 c 3 d 41 To4 Csee atso a 5 b 6 c 7 d 8 e 9 J 0
44. as of early 2013 required a clean shell environment to work If you wish to cross build manually please follow the steps below and or consult the release common sh source code Setup The easiest way to cross compile OpenSCAD for Windows on Linux or Mac is to use mxe M cross environment You will need to install git to get it Once you have git navigate to where 103 you want to keep the mxe files in a terminal window and run git clone git github com mxe mxe git Add the following line to your bashrc file export PATH lt where mxe is installed gt usr bin PATH replacing lt where mxe is installed gt with the appropriate path Requirements The requirements to cross compile for Windows are just the requirements of mxe They are listed along with a command for installing them here You don t need to type make this will make everything and take up gt 10 GB of diskspace You can instead follow the next step to compile only what s needed for openscad Now that you have the requirements for mxe installed you can build OpenSCAD s dependencies CGAL Opencsg MPFR and Eigen2 Just open a terminal window navigate to your mxe installation and run make mpfr eigen opencsg cgal qt This will take a few hours because it has to build things like gcc qt and boost Just go calibrate your printer or something while you wait To speed things up you might want do something like make J 4 JOBS 2 for parallel buil
45. ate a This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering 78 This image shows a 2D shape with a convexity of 4 as the ray indicated in red crosses the 2D shape a maximum of 4 times The convexity of a 3D shape would be determined in a similar way Setting it to 10 should work fine for most cases Extrude parameters for linear extrusion only height The extrusion height center If true the solid will be centered after extrusion twist The extrusion twist in degrees slices Similar to special variable fn without being passed down to the child 2D shape scale Scales the 2D shape by this value over the height of the extrusion a DXF Extrusion D The text in its current form is incomplete With the importQ and extrusion statements it is possible to convert 2D objects read from DXF files to 3D objects Linear Extrude Example of linear extrusion of a 2D object imported from a DXF file linear extrude height fanwidth center true convexity 10 import file example009 dxf layer fan top Rotate Extrude Example of rotational extrusion of a 2D object imported from a DXF file rotate extrude convexity 10 twist fanrot import file example009 dxf layer fan side origin fan side center 79 Getting Inkscape to work Inkscape is an open source drawing program Tutorials for transferring 2d DXF drawings from
46. atic linking in CMAKE under MS Visual C cmake org 111 imp declspec dllimport and unresolved references stackoverflow com OpenSCAD User Manual Building on Mac OS X lt OpenSCAD User Manual This page may need to be reviewed for quality For building OpenSCAD see https github com openscad openscad blob master README md For making release binaries see Http 7 Svieclitford at onetscad trunk doc check 11st macos txt OpenSCAD User Manual Libraries lt OpenSCAD User Manual This page may need to be reviewed for quality Contents e Library Locations e 2 Built in Libraries e 3 Other Libraries e 4 Old content Library Links e 4 1 Shapes by Catarina Mota e 4 2 Shapes by Giles Bathgate e 4 2 1 2D 2 2 2 aU e 4 3 Metric Fasteners by Giles Bathgate e 4 4 MCAD library e 4 5 ISO standard screw threads e 4 6 Sprockets for roller chain e 4 7 OpenSCAD Pinball Parts library Library Locations OpenSCAD places built in libraries in a system wide or bundled location For user supplied libraries there are two options l Use the built in user library path Li e Windows My Documents OpenSCAD libraries e Linux HOME lLocal share OpenSCAD libraries e Mac OS X HOME Documents OpenSCAD Libraries 2 Put your libraries anywhere and define the OPENSCADPATH environment variable to point to the library folder OPENSCADPATH can contain multiple paths in case you have library collections in mo
47. by rotate and zoom It s not possible to write to them and thus change the viewport parameters although that could be a decent enough idea Example cube 10 10 vpr 0 10 which makes the cube change size based on the view angle if an animation loop is active which does not need to use the t variable You can also make bits of a complex model vanish as you change the view The menu command Edit Paste Viewport Rotation Iranslation copies the current value of the viewport but not the current vpr or vpt User Defined Functions Define a function for code readability and re use Recursive function calls are supported necessitating the use of the Conditional Operator Tewe fae ake Usage examples my d 20 function r from dia my d my d 2 echo Diameter my d is radius r from dia my d recursion find the sum of the values in a vector array from the start or s th element to the i th element remember elements are zero based function sumv v 1 s 0 1 s v i v i sumv v i l1 s vec 10 20 30 40 echo sum vec sumv vec 2 1 is 20 30 50 Echo Statements This function prints the contents to the compilation window aka Console Useful for debugging code Also see the String function str The OpenSCAD console supports a subset of HIML markup language See here for details Usage examples my h 50 my r 100 echo This is a cylinder with h my h and r my r
48. cannot represent that exactly in IEEE floating point on a PC It comes out to 0 3333 going on to infinity The same goes for numbers like 0 6 there is actually no binary representation of the decimal number 0 6 in a finite number of binary digits The binary number system on a finite bit machine is not closed under division You can divide one finite digit binary floating point number by another and get a number thats not itself a finite digit binary floating point number Like 6 divided by 10 yielding 0 6 In fact this is not just a problem of binary numbers it s a problem of any number system that uses a decimal point and has a finite number of digits from the Ten based system decimals to Hexadecimal to Binary to anything But with Rationals this doesn t happen You can divide any rational number by any other rational and you wind up with another Rational and it is not infinite and there is no rounding involved So scaling down a 3d object made of Rational Points results in O rounding error scaling down a 3d object of floating point numbers will frequently result in rounding error Another nice feature of rationals is that if you have two lines whose end points or rise run or line equation are rational numbers their intersection point will also be a rational number with no rounding error Finite Floating Point numbers cannot guarantee that because of the division involved in solving the line equations Note that
49. cond point and then to the third point When looking at any triangle from the outside the triangle must list their 3 points ina clockwise order g General D The text in its current form is incomplete Comments OpenSCAD uses a programming language to create the models that are later displayed on the screen Comments are a way of leaving notes within the code either to yourself or to future programmers describing how the code works or what it does Comments are not evaluated by the compiler and should not be used to describe self evident code OpenSCAD uses C style comments This is a comment myvar 10 The rest of the line is a comment hs Multi line comments can span multiple Lines Variables Variables in OpenSCAD are simply a name followed by an assignment via an expression but see below for an important note about variables Example myvar 5 4 Currently it s not possible to do assignments at any place the only places are file top level and module top level If you need it inside the for loop for exemple you need to use the assign module Undefined variable A non assigned variable has a special value undef It could be tested in conditional expression and returned by a function Example echo Variable a is a output Variable a is undef if a undef echo Variable a is tested undefined function not _useful undef not really useful 20 echo F
50. d Install MinGW e Make sure you select the MSYS Basic System under components Extract downloaded win32_gmp_mpfr zip file to C win32 gmp mpfr Replace the mpfr and gmp h files in CGAL with the ones from win32 gmp mpfr e Delete or move to a temp folder all files in CGAL 3 7 auxiliary gmp include folder e Copy all the h files in C win32 gmp mpfr gmp Win32 Release to CGAL 3 7 auxillary gmp include e Copy all the h files in C win32 gmp mpfr mpfr Win32 Release to CGAL 3 7 auxillary gmp include e Replace the mpfr and gmp libs in CGAL with the ones from win32 gmp mpfr e Delete or move to a temp folder all 06 20 2011 libmpfr 4 lib is needed 7 19 11 i didnt need it files in CGAL 3 7 auxiliary gmp lib folder e Copy C win32 gmp mpfr gmp Win32 Release gmp lib to CGAL 3 7 auxillary gmp lib e Copy C win32 gmp mpfr mpfr Win32 Release mpfr lib to CGAL 3 7 auxillary gmp lib e Go into CGAL 3 7 auxiliary gmp lib and copy gmp lib to gmp vc90 mt s lib and mpfr lib to mpfr vc90 mt s lib so the linker can find them in the final link of openscad exe To get OpenSCAD source code e Open Git Bash or MingW Shell the installer may have put a shortcut on your desktop This launches a command line window e Type cd c to change the current directory e Type git clone git github com openscad openscad git This will put OpenSCAD source into C openscad Where to put other files I put all the dependencies in C so for example e C
51. d a value of 4 However at compile time the final value of echo p was actually 6 Therefore 6 will be shown on both echo p statements ECHO 6 a module test q p 2 q echo p p 4 q echo p Output ECHO 9 While this appears to be counter intuitive it allows you to do some interesting things For instance if you set up your shared library files to have default values defined as 23 variables at their root level when you include that file in your own code you can re define or override those constants by simply assigning a new value to them Exception 2 See the assign which provides for a more tightly scoped changing of values Getting input Now we have variables it would be nice to be able to get input into them instead of setting the values from code There are a few functions to read data from DXF files or you can set a variable with the D switch on the command line Getting a point from a drawing Getting a point is useful for reading an origin point ina 2D view in a technical drawing The function dxf cross will read the intersection of two lines on a layer you specify and return the intersection point This means that the point must be given with two lines in the DXF file and not a point entity OriginPoint dxf_cross file drawing dxf layer SCAD Origin Origin 0 0 scale 1 Getting a dimension value You can read dimensions from a technical drawing This can be
52. d from it The actual coordinates of the polygons that make up that cage shape are calculated by CGAL by calculating the intersections and unions of the half spaces involved Then it is converted to an ordinary polyhedron This can then be transformed into stl stereolithography files for output to a 3d printing system Ordinary Polyhedra CGAL s Nef Polyhedron is not the only type of Polyhedron representation inside of CGAL There is also the more basic CGAL Polyhedron 3 which here is called ordinary Polyhedra In fact many of OpenSCAD s routines will convert a CGAL Nef Polyhedron into an ordinary CGAL Polyhedron 3 The trick here is that ordinary Polyhedron 3 s have limits Namely this the polyhedral surface is always an orientable and oriented 2 manifold with border edges That basically means it only deals with water tight surfaces that don t have complicated issues like self intersection isolated lines and points etc A more exact explanation can be found here http www carliner remes com jacob math pro ject math htm The conversion between Nef Polyhedra and plain Polyhedron 3 can sometimes result in problems when using OpenSCAD issues In theory CGAL is seamless and consistent In actuality there are some documentation flaws bugs etc OpenSCAD tries to wrap calls to CGAL with exception catchers so the program won t crash every time the user tries to compile something Another intere
53. d subtract a donut this is not normalized Normalization forms the primitive objects into a tree where each leaf consists of a positive and negative object OpenSCAD does this normalization itself as can be seen in the log window during OpenCSG previews The Normalized CSG tree is then passed to OpenCSG for rendering Occasionally the normalization process blows up and freezes the machine making CGAL rendering the only way to view an object The number of objects during normalization is limited and can be changed in OpenSCAD preferences OpenCSG has it s own example source code that comes with the program It can help you to learn about the various OpenCSG rendering options Links e QpenCSG main website e Freenix 2005 slideshow on OpenCSG Goldfeather and Normalization e Freenix 2005 paper more detail on Goldfeather Normalization etc oe CGAL CGAL is the Computational Geometry Algorithm Library It contains a large collection of Geometry algorithms and methods by which objects can be represented It calculates the actual point sets of 3d objects which enables the output of 3d formats like SIL OpenSCAD uses two main features of CGAL the Nef Polyhedra and the ordinary Polyhedra It also uses various other functions like Triangulation amp c But the main data structures are the Nef and the ordinary Polyhedra Nef Polyhedra According to wikipedia s Nef Polyhedron article Nef Poly
54. design root Usage example lA s F Disable Modifier Simply ignore this entire subtree Usage example TE m Modules usage Defining your own module roughly comparable to a macro or a function in other languages is a powerful way to reuse procedures module hole distance rot size rotate a rot v 1 0 0 translate 0 distance 0 cylinder r size h 100 center true In this example passing in the parameters distance rot and size allow you to reuse this functionality multiple times saving many lines of code and rendering your program much easier to read You can instantiate the module by passing values or formulas for the parameters just like a C function call hole 0 90 10 children previously child Remark child is as of master deprecated and should be replaced by children with same parameters except cChild without parameters that should be replaced by children Q The latest stable release 2013 06 still uses child The child nodes of the module instantiation can be accessed using the children statement within the module Parameters empty select all the children index 52 integer select one child at index value index start at O and should be less than Schildren l vector vector of integer select children with index in vector Index should be between O and Schildren 1l range lt start gt lt end gt or lt start gt lt increme
55. development environment for OpenSCAD in Ubuntu 11 04 After executing the following steps QI Creator can be used to graphically start developing debugging OpenSCAD e Add required PPA repositories sudo add apt repository ppa chrysn openscad e Update and install required packages sudo apt get update sudo apt get install git build essential gqtcreator Libglewl 5 dev libopencsg dev Libcgal dev lLibeigen2 dev bison flex e Get the OpenSCAD sources mkdir src cd src git clone https github com openscad openscad git HH e Build OpenSCAD using the command line cd src openscad qmake make OH OH e Build OpenSCAD using QT Creator Just open the project file openscad pro CIRL 0 in QT Creator and hit the build all CTRL SHIFT B and run button CTRL R 102 The Clang Compiler There is experimental support for building with the Clang compiler under linux Clang is faster uses less RAM and has different error messages than GCC To use it first of all you will need CGAL of at least version 4 0 2 as prior versions have a bug that makes clang unusable Then run this script before you build OpenSCAD source scripts setenv unibuild sh clang Clang support depends on your system s QT installation having a clang enabled qmake conf file For example on Ubuntu this is under usr share qt4 mkspecs unsupported linux clang qmake conf BSD clang building may require a good deal of fiddling and is untested although e
56. ding See the mxe tutorial for more details Optional If you want to build an installer you need to install the nullsoft installer system It should be in your package manager called nsis Build OpenSCAD Now that all the requirements have been met all that remains is to build OpenSCAD itself Open a terminal window and enter git clone git github com openscad openscad git cd openscad Then get MCAD git submodule init git submodule update You need to create a symbolic link here for the build system to find the libraries ln s lt where mxe is installed gt usr i686 pc mingw32 mingw cross env again replacing lt where mxe is installed gt with the appropriate path Now to build OpenSCAD run 1686 pc mingw32 qmake CONFIG mingw cross env openscad pro make When that is finished you will have openscad exe in release and you can build an 104 installer with it as described in the instructions for building with Microsoft Visual C described here The difference is that instead of right clicking on the nsi file you will run makensis installer nsis Note that as of early 2013 OpenSCAD s scripts release common sh automatically uses the version of nsis that comes with the MXE cross build system so you may wish to investigate the release common sh source code to see how it works if you have troubles OpenSCAD User Manual Building on Windows lt OpenSCAD User Manual The latest reviewed version
57. e to confirm the proper settings Also look for MT in the CXXFLAGS line When it s done you can do the build nmake You should now have a CGAL vc90 mt s lib file under C CGAL 3 7 lib If not see Troubleshooting below OpenCSG Launch Visual Express cd C OpenCSG 1 3 2 vcexpress OpenCSG sln Substitute devenv for vcexpress if you are not using the express version e Manually step through project upgrade wizard e Make sure the runtime library settings for all projects is for Release not Debug e Click Build Configuration Manager e Select Release from Configuration drop down menu e Hit Close e Make sure the runtime library setting for OpenCSG project is set to multi threaded static e Open the OpenCSG project properties by clicking menu item Project gt OpenCSG Properties might be just Properties e Make sure it says Active Release in the Configuration drop down menu e Click Configuration Properties gt C C gt Code Generation e Make sure Runtime Library is set to Multi threaded MT e Click hit OK e Make sure the runtime library setting for glew static project is set to multi threaded static e In Solution Explorer OpenCSG pane click glew static project e Open the OpenCSG project properties by clicking menu item Project gt OpenCSG Properties might be just Properties e Make sure it says Active Release in the Configuration drop down menu 108 e Click C C gt
58. e 5 4 The Clang Compiler Prebuilt binary packages As of 2018 prebuilt OpenSCAD packages are available on many recent Linux and BSD distributions including Debian Ubuntu Fedora Arch and NetBSD Check your system s package manager for details For Ubuntu systems you can also try chrysn s Ubuntu packages at his launchpad PPA or you can just copy paste the following onto the command line sudo add apt repository ppa chrysn openscad Sudo apt get update sudo apt get install openscad His repositories for OpenSCAD and OpenCSG are here and here There is also a generic linux binary package at http www openscad org that can be unpacked and run from within most linux systems It is self contained and includes the required libraries Building OpenSCAD yourself If you wish to build OpenSCAD for yourself start by installing git on your system using your package manager Git is often packaged under the name scmgit or git core Then get the OpenSCAD source code cd git clone https github com openscad openscad git cd openscad Then get the MCAD library which is now included with OpenSCAD binary distributions 97 git submodule init git submodule update Installing dependencies Now download and install the dependency libraries and tools using your package manager This includes Qt4 CGAL GMP cmake MPFR boost OpenCSG GLEW Eigen2 GCC C Compiler Bison and Flex OpenSCAD comes with a helper script that will t
59. e and Render function F6 found in the Design menu To combine the benefits of those two display methods you can selectively wrap parts of your program in a render function and force them to be baken into a mesh even with OpenCSG mode enabled Implementation Details The acronym CGAL refers to The Open Source Computational Geometry Algorithms Library In CGAL mode the CGAL library is used to compute the mesh of the root object which is then displayed using simple OpenGL View options Show Edges Ctri 1 La The difference between the CGAL and OpenSCAD approaches can be seen at edges created by boolean operations If Show Edges is enabled both OpenCSG and CGAL mode will render edges as well as faces CGAL will even show vertices In CGAL grid mode this option has no effect Enabling this option shows the difference between OpenCSG and CGAL quite clearly While in CGAL mode you see an edge drawn everywhere it belongs OpenCSG will not show edges resulting from boolean operations this is because they were never explicitly calculated but are just where one object s Z clipping begins or ends Show Axes Ctri1 2 If Show Axes is enabled the origin of the global coordinate system will be indicated by an orthogonal axes indicator Additionally a smaller axes indicator with axes names will be shown in the lower left corner of the viewing area The smaller axes indicator is marked x y z and coloured red green blue respec
60. e surface also known as a wireframe Think of the Eiffel Tower A wire frame is a visual presentation of a three dimensional or physical object Using a wire frame model allows visualization of the underlying design structure of a 3D model Since wireframe renderings are relatively simple and fast to calculate they are often used in cases where a high screen frame rate is needed for instance when working with a particularly complex 3D model or in real time systems that model exterior phenomena When greater graphical detail is desired surface textures can be added automatically after completion of the initial rendering of the wireframe This allows the designer to quickly review changes or rotate the object to new desired views without long delays associated with more realistic rendering The wire frame format is also well suited and widely used in programming tool paths for DNC Direct Numerical Control machine tools Wireframe models are also used as the input for CAM computer aided manufacturing Wireframe is the most abstract and least realistic of the three main CAD models This method of modelling consists only of lines points and curves defining the edges of an object From Wikipedia http en wikipedia org wiki Wire frame model The OpenCSG View This view mode utilizes the open constructive solid geometry library to generate the model view utilizing OpenGL If the OpenCSG library is not available or the video card or drivers do
61. e with a height of 1 and move up 2 translate 0 0 2 dodecahedron 1 call the module with a height of 2 dodecahedron 2 call the module with a height of 4 and move down 4 translate 0 0 4 dodecahedron A4 Bounding Box Rather kludgy module for determining bounding box from intersecting projections module BoundingBox intersection translate 0 0 0 linear extrude height 1000 center true convexity 10 twist 0 projection cut false intersection rotate 0 90 0 linear extrude height 1000 center true convexity 10 twist 0 projection cut false rotate 0 90 0 children Q 895 rotate 90 0 0 linear extrude height 1000 center projection cut false rotate 90 0 0 children Q rotate 90 0 0 true convexity 10 twist linear extrude height 1000 center true convexity 10 twist 0 projection cut false rotate 90 0 0 intersection rotate 0 90 0 linear extrude height projection cut false rotate 0 90 0 children 0 rotate 0 0 0 linear extrude height projection cut false rotate 0 0 0 children 0 1000 center Test module on ellipsoid translate 0 0 40 scale 1 2 3 sphere r 5 BoundingBox scale 1 2 3 sphere r 5 1000 center true convexity true convexity 10 twist 10 twist OpenSCAD User Manual Using an external Editor with OpenSCAD lt OpenSCAD User Manual Thi
62. edges 70 Edges 35 Halffacets 32 Facets 16 Volumes 2 Total rendering time hours minutes seconds Rendering finished When you try to export this to STL you will get a message like Object isn t a valid 2 manifold Modify your design Manifold means that it is water tight and that there are no holes in the geometry In a valid 2 manifold each edge must connect exactly two facets That means that the program must be able to connect a face with an object E g if you use a cube of height 10 to carve out something from a wider cube of height 10 it is not clear to which cube the top or the bottom belongs So make the small extracting cube a bit longer or shorter difference original cube size 2 2 2 object that carves out translate 0 5 0 5 0 5 cube size 1 1 3 82 Correct use of difference Here is a more tricky little example taken from the OpenSCAD Forum retrieved 15 13 22 March 2010 UTC module examplel cube 20 20 20 translate 20 20 0 cube 20 20 20 cube 50 50 5 center true module example2 cube 20 1 20 1 20 translate 20 20 0 cube 20 1 20 1 20 cube 50 50 5 center true Examplel would render like this 83 A not valid 2 manifold cube simple no The examplel module is not a valid 2 manifold because both cubes are sharing one edge They touch each other but do not intersect Examp
63. es e 1 3 3 2 Extrude parameters for linear extrusion only e 1 4 DXF Extrusion e 1 4 1 Linear Extrude e 1 4 2 Rotate Extrude e 1 4 3 Getting Inkscape to work e 1 4 4 Description of extrude parameters e 1 4 4 1 Extrude parameters for all extrusion modes e 1 4 4 2 Extrude parameters for linear extrusion only 65 o 2D Primitives All 2D primitives can be transformed with 3D transformations Usually used as part of a 8D extrusion Although infinitely thin they are rendered with a 1 thickness square Creates a square at the origin of the coordinate system When center is true the square will be centered on the origin otherwise it is created in the first quadrant The argument names are optional if the arguments are given in the same order as specified in the parameters Parameters size Decimal or 2 value array If a single number is given the result will be a square with sides of that length If a 2 value array is given then the values will correspond to the lengths of the X and Y sides Default value is 1 center Boolean This determines the positioning of the object If true object is centered at 0 0 Otherwise the square is placed in the positive quadrant with one corner at 0 0 Defaults to false Example square 2 2 center true circle Creates a circle at the origin of the coordinate system The argument name is optional Parameters Decimal This is the radius of the circle The resolution of the circ
64. es like this can really cause issues if there are stray libraries in unusual places Another source of confusion can come from running from within an unclean shell Make sure that you don t have LD LIBRARY PATH set to point to any old libraries in any strange places Also don t mix a Mingw windows cross build with your linux build process they use different environment variables and may conflict OpenCSG didn t automatically build If for some reason the recommended build process above fails to work with OpenCSG please file an issue on the OpenSCAD github In the meantime you can try building it yourself wget http www opencsg org OpenCSG 1 3 2 tar gz sudo apt get purge libopencsg dev Libopencsgl or your system s equivalent tar xvf OpenCSG 1 3 2 tar gz cd OpenCSG 1 3 2 edit the Makefile and remove example make sudo cp d lib lib HOME openscad deps lib sudo cp include opencsg h HOME openscad deps include Note on Debian based systems such as Ubuntu you can add the install target to the OpenCSG Makefile and then use checkinstall to create a clean deb package for install removal upsrade Add this target to Makefile install THESE LINES PREFIXED WITH ONE TAB NOT SPACES cp d Llib lib usr local lib cp include opencsg h usr local include ldconfig Then sudo checkinstall D make install to create and install a clean package CGAL didn t automatically build If this happens you can
65. g the following t values and saved in the following files e t 0 Steps filename frame00001 png e t 1 Steps filename frame00002 png e t 2 Steps filename frame00003 png e t 1 3 Steps filename frame lt Steps 2 gt png e t 1 2 Steps filename frame lt Steps 1 gt png e t 1 1 Steps filename frame00000 png Or for other values of Steps it follows this pattern e t 0 Steps filename frame00001 png e t 1 Steps filename frame00002 png e t 2 Steps filename frame00003 png e t 1 3 Steps filename frame lt Steps 2 gt png e t 1 2 Steps filename frame lt Steps 1 gt png e t 1 1 Steps filename frame lt Steps 0 gt png e t 1 0 Steps filename frame00000 png Which pattern it chooses appears to be an unpredictable but consistent function of Steps For example when Steps 4 it follows the first pattern and outputs a total of 4 files When Steps 3 it follows the second pattern and also outputs 4 files It will always output either Steps or Steps l files though it may not be predictable which When finished it will wrap around and recreate each of the files looping through and recreating them forever vpr and vpt These contain the current viewport rotation and translation at the time of doing the rendering Moving he viewport does not update them During an animation they are updated for each frame e vpr shows rotation 58 e vpt shows translation i e won t be affected
66. gin Sfa Angle in degrees Sfs Angle in mm Sin Resolution Usage Examples cylinder h 10 r 20 cylinder h 10 r 20 fs 6 cylinder h 10 rl 10 r2 20 center false cylinder h 10 rl 20 r2 10 center true cylinder h 10 d 40 cylinder h 10 d 40 fs 6 cylinder h 10 dl 20 d2 40 center false cylinder h 10 dl 40 d2 20 center true cylinder h 10 rl 20 cylinder h r2 10 center true 0 r 20 if pe a w eld EA polyhedron Create a polyhedron with a list of points and a list of triangles The point list is all the vertexes of the shape the triangle list is how the points relates to the surfaces of the polyhedron Parameters points vector of points or vertexes each a 3 vector triangles vector of point triplets each a 3 number vector Each number is the O indexed point number from the point vector convexity 16 Integer The convexity parameter specifies the maximum number of front sides back sides a ray intersecting the object might penetrate This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering Syntax example polyhedron points x y z triangles pl p2 p3 convexity N Triangle points ordering When looking at the face from the outside inwards the points must be clockwise You can rearrange the o
67. gt CSG Modelling union difference intersection render convexity lt value gt Modifier Characters Ignore the rest of the design and use this subtree as design root Ignore this subtree Ignore CSG of this subtree and draw it in transparent gray Use this subtree as usual but draw it in transparent pink oP BSAA AK 118 Modules module name lt varl gt lt var2 gt lt module code gt Variables can be default initialized lt yvarl gt lt defaultvalue gt In module you can use Children to refer to all child nodes or children 1 where 1 is between O and children Include Statement After 2010 02 include lt filename scad gt appends whole file use lt filename scad gt appends ONLY modules and functions filename could use directory with char separator Prior to 2010 02 lt filename scad gt Other Language Features fa is the minimum angle for a fragment The default value is 12 degrees fs is the minimum size of a fragment The default value is 1 fn is the number of fragments The default value is Q When fa and fs are used to determine the number of fragments for a circle then OpenSCAD will never use less than 5 fragments t The St variable is used for animation If you enable the animation frame with view gt animate and give a value for FPS and Steps the Time field shows the curre
68. gument to mirror is the normal vector of a plane intersecting the origin through which to mirror the object Usage example mirror 0 1 0 4 3 mirror 1 0 0 mirror 1 1 0 42 mirror 1 1 1 rotate 0 0 10 cube 3 2 1 mirror 1 0 0 translate 1 0 0 rotate 0 0 10 cube 3 2 1 multmatrix Multiplies the geometry of all child elements with the given 4x4 transformation matrix Usage multmatrix m D Example translates by 10 20 30 multmatrix m 1 0 0 10 0 1 0 20 0 0 1 30 0 0 1 cylinder Example rotates by 45 degrees in XY plane and translates by 10 20 30 ang le 45 multmatrix m cos angle sin angle 0 10 sin angle cos angle 0 20 0 0 1 30 0 0 0 1 union cy Linder r 10 0 h 10 center false cube size 10 10 10 center false 43 color Displays the child elements using the specified RGB color alpha value This is only used for the F5 preview as CGAL and STL F6 do not currently support color The alpha value will default to 1 0 opaque if not specified Usage example color r g b al Note that the r g b a values are limited to floating point values in the range 0 0 1 0 rather than the more traditional integers 0 values as fractions e g for R G B integers in 0 color R 255 G 255 B 255 255 However you can specify the
69. hedrons are named after Walter Nef who wrote a book on Polyhedrons named Beitr ge zur Theorie der Polyeder published in 1978 by Herbert Lang in Bern Switzerland A very rough explanation of the theory goes like this imagine you can create a plane that divides the universe in half Now imagine you can mark one side to be the inside and the other side to be the outside Now imagine you take several of these planes and arrange them for example as if they were walls of a room and a ceiling and a floor Now lets just imagine the inside of all of these planes and now imagine that you do an intersection operation on them like a venn diagram or any other boolean operation on sets You will find that this intersection forms a cuboid from the outside it just looks like a box This box is the Nef Polyhedron In other terms you have created a polyhedron by doing boolean operations on half spaces halves of the universe Why would you go to all this trouble Why not just use plain old points in space and triangle faces and be done with it Well Nef Polyhedrons have certain properties that make boolean operations on them work better than boolean operations between meshes in theory CGAL s Nef Polyhedron code calculates the resulting 3 dimensional points of the new shapes generated when you perform CSG operations Let s take example 4 from OpenSCAD s example programs It is a cube with a sphere subtracte
70. hematical Functions e 1 7 1 abs e 1 7 2 ceil e 1 7 3 exp e 1 7 4 floor baie 1n e 1 7 6 len e 1 7 7 log e 1 7 8 lookup e 1 7 9 max e 1 7 10 min e 1 7 11 norm e 1 7 12 pow e 1 7 13 rands e 1 7 14 round e 1 7 15 sign e 1 7 16 sqrt e 1 8 String Functions e 1 8 1 str e 1 8 2 Also See search e 1 9 Transformations e 1 9 1 scale e 1 9 2 resize e 1 9 3 rotate e l 9 4 translate ea Mirror e 1 9 6 multmatrix e 1 9 7 color e 1 9 8 minkowski e 1 9 9 hull e 1 10 CSG Modeling e 1 10 1 union e 1 10 2 difference e 1 10 3 intersection e 1 10 4 render e 1 11 Modifier Characters e 1 11 1 Background Modifier e 1 11 2 Debug Modifier e 1 11 3 Root Modifier e 1 11 4 Disable Modifier e 1 12 Modules e 1 12 1 usage e 1 12 2 children reviously child e 1 12 3 arguments e 1 13 Importing Geometry JJ3 import e 1 18 2 import stl e 1 14 Include Statement e 1 15 Other Language Features e 1 15 1 Special variables e 15 1 1 Sta Sis and Sta Jeibehee Pt e 1 15 1 3 vpr and vpt 15 2 User Defined Functions e 1 1 e 1 15 3 Echo Statements e 1 15 4 Render e 1 15 5 Surface e 1 15 6 Search e 1 15 6 1 Search Usage e 1 15 6 2 Search Arguments e 1 15 6 3 Search Usage Examples m m l ad 1 al al 5 6 3 1 Index values return as list 6 3 2 Search on different column return Index values 6 90 36 Search on list of valves 56 074 Search of list o
71. ho render surface search version amp version num 5 fl Using the 2D Subsystem 2D Primitives square circle polygon amp import dxf 3D to 2D Projection projection 2D to 3D Extrusion linear extrude amp rotate extrude DXF EXtrusion Other 2D formats 6 STL Import and Export 1 SIL Import 2 LL BE epor 7 Commented Example Projects 8 H Using an external Editor with OpenSCAD 9 fe Using OpenSCAD in a command line environment 10 fa Building OpenSCAD from Sources 1 Building on Linux UNIX 2 Cross compiling for Windows on Linux or Mac OS X 3 Building on Windows 4 Building on Mac OS X 5 Submitting patches 11 fslLibraries 12 4lCommand Glossary Very short name and syntax reference HY GC N e u DN Ol OF WHF OpenSCAD User Manual Introduction lt OpenSCAD User Manual The latest reviewed version was checked on 15 October 2013 There are 4 pending changes awaiting review OpenSCAD is a software for creating solid 3D CAD objects It is free software and available for GNU Linux MS Windows and Apple OS X Unlike most free software for creating 3D models such as the well known application Blender OpenSCAD does not focus on the artistic aspects of 3D modelling but instead focuses on the CAD aspects So it might be the application you are looking for when you are planning to create 3D models of machine parts but probably is not what you are looking for when you are more interested in c
72. imilar to cube 5 v s cube 5 5 5 log Mathematical logarithm See Logarithm lookup Look up value in table and linearly interpolate if there s no exact match The first argument is the value to look up The second is the lookup table a vector of key value pairs Parameters key A lookup key lt key value gt array keys and values Notes There is a bug where out of range keys will return the first value in the list Newer versions of Openscad should use the top or bottom end of the table as appropriate instead Usage example e Will create a sort of 3D chart made out of cylinders of different height 33 function get cylinder h p lookup p I 200 5 50 20 J 20 18 80 25 150 2 l for i 100 5 100 echo i get cylinder h i pmj translate i 0 30 cylinder rl 6 r2 2 h get cylinder h i 3 OpenSCAD Looku max Returns the maximum of the two parameters Parameters lt a gt Decimal lt b gt Decimal Usage Example max 3 0 5 0 max 8 0 3 0 Results 5 0 8 0 min Returns the minimum of the two parameters Parameters lt a gt Decimal lt b gt Decimal Usage Example min 3 0 5 0 min 8s 0 3 0 Results 3 0 3 0 34 Looking for mod it s not a function see modulo operator norm Note this function is not in 2013 01 and is pending pull request https github com openscad openscad pull 333 Re
73. in things like modularity and portability As of mid 2013 it was possible to build the test suites entirely without QT Other libraries amp library versions OpenSCAD also depends on Boost the Eigen math library and the GLEW OpenGL extension helper library In order to actually build OpenSCAD and compile and run the self diagnostic tests OpenSCAD also needs tools like git cmake and ImageMagick Version numbers can be very important They are listed in a readme file in the root of the OpenSCAD source code Using libraries that are too old will result in an OpenSCAD that exhibits bizarre behavior or crashes Submitting Patches See http en wikibooks org wiki OpenSCAD User Manual Submitting patches OpenSCAD User Manual Building on Linux UNIX lt OpenSCAD User Manual 96 Contents e Prebuilt binary packages e 2 Building OpenSCAD yourself e 2 1 Installing dependencies e 2 2 Building the dependencies yourself e 2 3 Build the OpenSCAD binary e 3 Compiling the test suite e 4 Troubleshooting e 4 1 Errors about incompatible library versions e 4 2 OpenCSG didn t automatically build e 4 3 CGAL didn t automatically build e 4 4 Compiling is horribly slow and or grinds the disk e 4 5 BSD issues e 4 6 Test suite problems e 4 7 I moved the dependencies I built and now openscad won t run e 5 Tricks and tips e 5 1 Reduce space of dependency build e 5 2 Preferences e 5 3 Setup environment to start developing OpenSCAD in Ubuntu 11 04
74. inker errors about conflicting symbols in LIBCMT and LIBCMID dumpbin exe can also help you understand errors involving unresolved external symbols For example if you get an error about unresolved external symbol GLEW NV occlusion query but your VERBOSE error log says the program linked in glew32 lib then you can dumpbin exe all glew32 lib find i occlusion to see if the symbol is actually there You may see a mangled symbol with impl which gives you another clue with which you can google In this particular example glew32s lib s static 110 should have been linked instead of glew32 1ib CGAL CGAL vc90 mt s lib After compilation it is possible that you might get a file named CGAL vc90 mt lib or CGAL vc90 mt gd lib instead of CGAL vc90 mt s lib There are many possibilities you accidentally built the wrong version or you may have built the right version and VCExpress named it wrong To double check and fix the problem you can do the following cd C CGAL 3 7 1lib dumpbin all CGAL vc90 mt lib find i DEFAULTLIB 1f you have mt gd use that name instead If this shows lines referencing LIBCMTD MSVCRT or MSVCRID then you accidentally built the debug and or dynamic version and you need to clean the build and try to build again with proper settings to get the multi threaded static release version However if it just says LIBCMT then you are probably OK Look for another line saying DEFAULTLIB CGAL vc90 m
75. is way you can keep track Clockwise Technique Orientation is determined by clockwise indexing This means that if you re looking at the triangle in this case 4 0 5 from the outside you ll see that the path is clockwise around the center of the face The winding order 4 0 5 is clockwise and therefore good The winding order 0 4 5 is counter clockwise and therefore bad Likewise any other clockwise order of 4 0 5 works 5 4 0 amp 0 5 4 are good too If you use the clockwise technique you ll always have your faces outside outside of OpenSCAD other programs do use counter clockwise as the outside though Think of it as a Left Hand Rule If you hold the triangle and the fingers of your hand curls is the same order as the points then your thumb points outwards Polyhedron with badly oriented polygons Succinct description of a Polyhedron Points define all of the points vertices in the shape Triangles is a list of triangles that connect up the points vertices Each point in the point list is defined with a 3 tuple x y z position specification T3 Points in the point list are automatically given an identifier starting at zero for use in the triangle list 0 1 2 3 etc Each triangle in the triangle list is defined by selecting 3 of the points using the point identifier out of the point list e g triangles 0 1 2 defines a triangle from the first point points are zero referenced to the se
76. l strings OI JOI JOT JOI 15 6 3 5 Getting the right results e 1 15 7 OpenSCAD Version o Primitive Solids cube Creates a cube at the origin of the coordinate system When center is true the cube will be 13 centered on the origin otherwise it is created in the first octant The argument names are optional if the arguments are given in the same order as specified in the parameters Parameters size Decimal or 3 value array If a single number is given the result will be a cube with sides of that length If a 3 value array is given then the values will correspond to the lengths of the X Y and Z sides Default value is 1 center Boolean This determines the positioning of the object If true object is centered at 0 0 0 Otherwise the cube is placed in the positive quadrant with one corner at 0 0 0 Defaults to false Usage examples 1 center false 1 2 3 center true cube size cube size cube size 1 cube size 1 2 3 center false center true sphere Creates a sphere at the origin of the coordinate system The argument name is optional Parameters r Decimal This is the radius of the sphere The resolution of the sphere will be based on the size of the sphere and the fa fs and fn variables For more information on these special variables look at OpenSCAD User Manual Other Language Features d Decimal This is the diameter of the sphere fa Fragment angle in degrees
77. late 6 0 0 house roof pitched paint 0 0 1 translate 8 0 0 house paint 0 0 0 roof pitched translate 10 0 0 house roof domical translate 12 0 0 house paint 0 0 5 0 5 Importing Geometr D The text in its current form is incomplete import Imports a file for use in the current OpenSCAD model Parameters lt file gt A string containing the path to the STL or DXF file Usage examples import exampleQ12 stl Notes In the latest version of OpenSCAD import Q is now used for importing both 2D DXF for extrusion and 3D STL files import_stl lt DEPRECATED Use the command import instead gt Imports an SIL file for use in the current OpenSCAD model Parameters lt file gt A string containing the path to the STL file to include lt convexity gt 54 Integer The convexity parameter specifies the maximum number of front sides back sides a ray intersecting the object might penetrate This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering Usage examples import stl example012 stl convexity 5 Include Statement D The text in its current form is incomplete For including code from external files in OpenSCAD there are two commands available e include lt filename gt acts as if the contents of the included file were written in the including file and e use lt filename gt imports modules
78. ld greatly aid such a transition Value The Value class is OpenSCAD s way of representing numbers strings boolean variables vectors amp c OpenSCAD uses this to bridge the gap between the scad source code and the guts of it s various engines value h and value cc use the boost variant feature sort of like C unions but nicer node You will notice that most important pieces derive from the AbstractNode class Various conventions and patterns are the same between different nodes so when implementing new features or fixing bugs it can be helpful to simply look at the way things are done by comparing nodes For example transformnode h and transform cc show the basic setup of how something like scale goes from source code in a context into a member variable of the transformnode node matrix which is then used by CGALEvaluator cc to actually do a transform on the 3d object data This can be compared with colornode lineartextrudenode etc Polyset PolySet is a sort of inbetween glue class that represents 3d objects in various stages of processing All primitives are first created as a PolySet and then transformed later if necessary into CGAL forms OpenSCAD currently converts all import into a PolySet before converting to CGAL Nef polyhedra or CGAL ordinary polyhedra 95 DXF stuff As of early 2013 OpenSCAD s 2d subsystem relies heavily on DXF format an old format used in Autocad and created by A
79. le will be based on the size of the circle If you need a small high resolution circle you can get around this by making a large circle then scaling it down by an appropriate factor or you could set fn or other special variables Default value is 1 d Decimal This is the diameter of the circle The resolution of the circle will be based on the size of the circle If you need a small high resolution circle you can get around this by making a large circle then scaling it down by an appropriate factor or you could set fn or other special variables Default value is 1 Examples circle uses default radius r 1 10 20 circle r circle d scale 1 100 1 100 1 100 circle 200 this will create a high resolution circle with a 2mm radius circle 2 fn 50 Another way to create a high resolution circle with a radius of 2 66 polygon Create a polygon with the specified points and paths Parameters points vector of 2 element vectors ie the list of points of the polygon paths Either a single vector enumerating the point list ie the order to traverse the points or a vector of vectors ie a list of point lists for each seperate curve of the polygon The latter is required if the polygon has holes The parameter is optional and if omitted the points are assumed in order The pN components of the paths vector are O indexed references to the elements of the points vector convexity Integer Number of inwa
80. le2 is a valid 2 manifold because there is an intersection Now the construct meets the 2 manifold constraint stipulating that each edge must connect exactly two facets Pieces you are subtracting must extend past the original part OpenSCAD Tip Manifold Space and Time retrieved 18 40 22 March 2010 UTC For reference another situation that causes the design to be non exportable is when two faces that are each the result of a subtraction touch Then the error message comes up difference cube 20 10 10 translate 10 0 0 cube 10 difference cube 20 10 10 cube 10 simply touching surfaces is correctly handled translate 10 0 0 cube 10 cube 10 OpenSCAD User Manual Commented Example Projects 84 lt OpenSCAD User Manual The latest reviewed version was checked on 16 January 2013 There is 1 pending change awaiting review D The text in its current form is incomplete Dodecahedron create a dodecahedron by intersecting 6 boxes module dodecahedron height scale height height height scale by height parameter intersection make a cube cube 2 2 1 center true intersection for i 0 4 loop i from 0 to 4 and intersect results make a cube rotate it 116 565 degrees around the X axis then 72 1 around the Z axis rotate 0 0 72 1 rotate 116 565 0 0 cube 2 2 1 center true create 3 stacked dodecahedra call the modul
81. loborodko com pavel downloads win32 gmp mpfr zip MinGW http netcologne dl sourceforge net pro jject mingw Automated 20MinGW 20 I nstaller mingw get inst mingw get inst 20110316 mingw get inst 20110316 exe Installing 106 Install Visual Studio e No need for siverlight or mssql express e You can use a virtual CD program like MagicDisc to mount the ISO file and install without using a CD Install QT e Install to default location C Qt 4 7 2 Install Git e Click Run Git and included Unix tools from the Windows Command Prompt despite the big red letters warning you not to Install Cmake e Check the Add cmake to the system path for the current user checkbox e Install to default location C Program Files CMake 2 8 Install Boost e Select the VC 9 0 vs2008 radio e Check the multithreaded static runtime checkbox only e Install into C boost_ 1 46 1 Install CGAL e Note CGAL 3 9 fixes several bugs in earlier versions of CGAL but CGAL 3 9 will not compile under MSVC without extensive patching Please keep that in mind when compiling OpenSCAD with MSVC there may be bugs due to the outdated version of CGAL required to use MSVC e Note its not a binary distribution just an installer that installs the source e No need for CGAL Examples and Demos e Make sure mpfr and gmp precompiled libs is checked e The installer wants you to put this in C Program Files CGAL 3 7 I used C CGAL 3 7 e Make sure CGAL DIR environment checke
82. n in CGAL s CGAL 3d Boolean operations on Nef Polyhedra Notice any familiar colors e ordinary CGAL Polyhedron 3 e Nef polyhedron wikipedia Throwntogether The Throwntogether renderer is a fall back quick preview renderer that OpenSCAD can use if OpenCSG is not available It should work on even the most minimal of OpenGL systems It s main drawback is that it renders negative spaces as big opaque green blocks instead of as cut outs of the positive spaces This can hide a lot of the internal detail of a shape and make use of OpenSCAD more difficult The intersection command for example does not do anything it simply displays the full intersection shapes as if they were a union However by hitting F6 the user can still compile the object into CGAL and see the shape as it is intended Under what circumstances does the program fall back to Throwntogether instead of using OpenCSG preview In cases where the OpenGL machine does not support Stencil Buffers and cannot draw Offscreen images with Framebuffer Objects FBOs If the user finds that OpenCSG support is buggy on their system they can also manually switch to throwntogether mode through the menus Source Code Notes Ifdefs The design of the code is so that in theory CGAL and or OpenCSG can be disabled or enabled In practice this doesn t always work and tweaking is needed But if some day the underlying engines were to be replaced this feature of the code wou
83. nce cylinder r rl h h translate 0 0 1 cylinder r r2 h h 2 ring 5 4 10 Including the library using include lt ring scad gt rotate 90 0 0 ring 10 1 1 would result in the example ring being shown in addition to the rotated ring but 59 use lt ring scad gt rotate 90 0 0 ring 10 1 1 only shows the rotated ring Default variables in an include can be overridden for example lib scad i l k 3 module x 4 echo hello world echo i i j j k k hello scad 4 include lt lib scad gt X 1 5 X k j X Produces the following ECHO hello world ECHO i 5 j 4 ECHO hello world ECHO i 5 j 4 ECHO hello world ECHO i 5 j 4 However placing j 4 after the include fails producing ECHO hello world ECHO i 5 j 4 ECHO hello world ECHO i 5 j 4 ECHO hello world ECHO i 5 j 4 i k i 4 i k lI i 4 lI k lI 4 k undef k undef k undef o Other Language Features D The text in its current form is incomplete Special variables All variables starting with a are special variables The semantic is similar to the special variables in lisp they have dynamic instead of lexical scoping What that means is that they re effectively automatically passed onward as arguments Comparing a normal with a special variable 56 no
84. ng methods and other options using the View menu Most of the options described here are available using shortcuts as well Render modes OpenCSG F9 This method produces instantaneous results but has low frame rates when working with highly nonconvex objects Note that selecting the OpenCSG mode using F9 will switch to the last generated OpenCSG view but will not re evaluate the source code You may want to use the Compile function F5 found in the Design menu to re evaluate the source code build the OpenCSG objects and then switch to OpenCSG view Implementation Details In OpenCSG mode the OpenCSG library is used for generating the visible model This library uses advanced OpenGL features 2 0 like the Z buffer and does not require an explicit description of the resulting mesh instead it tracks how objects are to be combined For example when rendering a spherical dent in a cube it will first render the cube on the graphics card and then render the sphere but instead of using the Z buffer to hide the parts of the sphere that are covered by the cube it will render only those parts of the sphere visually resulting in a cube with a spherical dent CGAL Surfaces and Grid F10 and F11 This method might need some time when first used with a new program but will then have higher framerates As before with OpenCSG F10 and F1ll only enable CGAL display mode and don t update the underlying objects for that use the Compil
85. nt e popbumpers llo e standup targets e flippers e lane guides e plunger amp launch lane e drop targets e posts e studs e vertical up kicker OpenSCAD User Manual Command Glossary lt OpenSCAD User Manual a The latest reviewed version was checked on 24 June 2013 There are 2 pending changes awaiting review This is a Quick Reference a short summary of all the commands without examples just the basic syntax The headings are links to the full chapters Contents e Mathematical Operators Mathematical Functions String Functions Primitive Solids Transformations Conditional and Iterator Functions CSG Modelling Modifier Characters Modules e 10 Include Statement e Other Language Features e 12 2D Primitives e 13 3D to 2D Projection e 14 2D to 3D Extrusion e I5 DXF Extrusion e 16 STL Import CO Jo IN IO JOI Te o do Mathematical Operators also as unary negative x EL amp amp logical and Logical or logical not lt boolean gt lt valIfTrue gt lt vallfFalse gt Mathematical Functions abs lt value gt cos lt degrees gt Sin lt degrees gt tan lt degrees gt asin lt value gt acos lt value gt atan lt value gt atan2 lt y value gt lt x value gt pow lt base gt lt exponent gt len lt string gt len lt vector gt len lt vector of vectors gt min lt valuel gt lt value2 gt
86. nt gt lt end gt select children between lt start gt to lt end gt incremented by lt increment gt default 1 Number of module children is accessed by Schildren variable Examples Transfer all children to another module rotate to other center point module rz angle center undef trans late center rotate angle trans late center children rz 15 10 0 sphere 30 Use the first child multiple time module lLineup num space for i 0 num 1 translate space i 0 0 children Q0 Lineup 5 65 sphere 30 If you need to make your module iterate over all children you will need to make use of the Schildren variable e g module elongate for i 0 children 1 scale 10 1 1 children 1i elongate sphere 30 cube 10 10 10 cylinder r 10 h 50 arguments One can specify default values for the arguments module house roof flat paint 1 0 0 color paint if roof Fflat translate 0 1 0 cube else if roof pitched rotate 90 0 0 53 linear extrude height 1 polygon points 0 0 0 1 0 5 1 5 1 1 1 0 paths 0 1 2 3 4 l else if roof domical translate 0 1 0 union translate 0 5 0 5 1 sphere r 0 5 fn 20 cube And then use one of the following ways to supply the arguments union house translate 2 0 0 house pitched translate 4 0 0 house domical 0 1 0 trans
87. nt value of t function name lt var gt f lt var gt echo lt string gt lt var gt render convexity lt val gt surface file filename dat center lt boolean gt convexity lt val gt 2D Primitives Square size Square size lt val gt center lt boolean gt x y center lt boolean gt Circle r lt val gt polygon points x y paths pl p2 p3 convexity N Lo 3D to 2D Projection projection cut lt boolean gt 2D to 3D Extrusion linear extrude height lt val gt center lt boolean gt convexity lt val gt twist lt degrees gt Slices lt val gt fn fs fa rotate extrude convexity lt val gt fn DXF Extrusion linear extrude file filename dxf layer Layername height lt val gt center lt boolean gt convexity lt val gt twist lt degrees gt rotate extrude file filename dxf layer Layername origin x y convexity lt val gt fn f STL Import import stl filename stl convexity lt val gt 120
88. ou can just run scripts uni build dependencies sh cgal or opencsg and it will only build a single library The complete download and build process can take anywhere from half an hour to several hours depending on your network connection speed and system speed It is recommended to have at least 1 5 Gigabyte of free disk space to do the full dependency build Each time you log into a new shell and wish to re compile OpenSCAD you need to re run the source scripts setenv unibuild sh script After completion re check while running under the same shell with the same environment variables set to see if it worked scripts check dependencies sh 98 Build the OpenSCAD binary Once you have either downloaded or built the dependencies you can build OpenSCAD qmake or qmake qt4 depending on your distribution make You can also install OpenSCAD to usr local if you wish The openscad binary will be put under usr local bin the libraries and examples will be under something like usr local share openscad possibly depending on your system Note that if you have previously installed a binary linux package of openscad you should take care to delete usr local lib openscad and usr local share openscad because they are not the same paths as what the standard qmake built install target uses sudo make install Note on Debian based systems create a package and install OpenSCAD using sudo checkinstall D make install If you
89. own fox jumps over the lazy dog The quick brown fox The lazy dog Output in OpenSCAD version 2013 02 28 ECHO The quick brown fox tjumps over the lazy dog The quick brown fox nThe lazy dog Variables are set at compile time not run time Because OpenSCAD calculates its variable values at compile time not run time the last variable assignment will apply everywhere the variable is used with some exceptions mentioned below It may be helpful to think of them as override able constants rather than as variables Example The value of a reflects only the last set value a 0 echo a a 5 echo a Output ECHO 5 ECHO 5 This also means that you can not reassign a variable inside an if block Example a 0 if a 0 a 1 lt this line will generate an error Output Compile Error Exception 1 This behavior is scoped to either the root or to a specific call to a module meaning you can re define a variable within a module without affecting its value outside of it However all instances within that call will behave as described above with the last set value being used throughout Example p 4 test 5 echo p we start with p 4 We step to the next command test 5 which calls the test module The test module calculates two values for p but the program will ONLY display the final value There will be two executions of echo p inside tes
90. pected images to the test run generated actual images You can try using the alternate ImageMagick comparison method by by erasing CMakeCache and re running cmake with DCOMPARATOR ncc This will enable the Normalized Cross Comparison method which is more stable but possibly less accurate and may give false positives or negatives 101 Testing images fails with morphology not found for ImageMagick in the log Your version of imagemagick is old Upgrade imagemagick or pass DCOMPARATOR old to cmake The comparison will be of lowered reliability I moved the dependencies I built and now openscad won t run It isn t advised to move them because the build is using RPATH hard coded into the openscad binary You may try to workaround by setting the LD LIBRARY PATH environment variable to place yourpath lib first in the list of paths it searches If all else fails you can re run the entire dependency build process but export the BASEDIR environment variable to your desired location before you run the script to set environment variables Tricks and tips Reduce space of dependency build After you have built the dependencies you can free up space by removing the BASEDIR src directory where SBASEDIR defaults to S HOME openscad deps Preferences OpenSCAD s config file is kept in config OpenSCAD OpenSCAD conf Setup environment to start developing OpenSCAD in Ubuntu 11 04 The following paragraph describes an easy way to setup a
91. pper for openscad exe This is because Openscad uses the devenv solution to the Command Line GUI output issue Typing openscad at the cmd exe prompt will by default call the com program wrapper OpenSCAD User Manual Building OpenSCAD from Sources lt OpenSCAD User Manual Most users will want to download the pre compiled binary installation packages from the main http www openscad org website However you can compile the OpenSCAD source yourself if you so desire It will allow you to experiment with new features and bug fixes in the development versions It will also expose you to certain accidental breaks and bugs during the development process It is highly recommended you join the openscad developers mailing list if you are experimenting with the latest source code This page provides general information You can find specific step by step instructions on the following pages e QpenSCAD User Manual Building on Linux UNIX e QpenSCAD User Manual Cross compiling for Windows on Linux or Mac OS X e QpenSCAD User Manual Building on Windows e QpenSCAD User Manual Building on Mac OS X e QpenSCAD User Manual Submitting patches gl Contents e Structure of OpenSCAD e 1 1 OpenCSG e 1 2 CGAL e 1 38 CGAL and GMPQ e 1 4 Throwntogether e 1 5 Source Code Notes e 1 6 Library notes e 2 Submitting Patches Structure of OpenSCAD OpenSCAD as of 2011 relies heavily on two other projects the OpenCSG library and
92. rd curves ie expected path crossings of an arbitraty line through the polygon Usage polygon points x y paths pl p2 p3 convexity N Example polygon points 0 0 100 0 0 100 10 10 80 10 10 80 paths 0 1 2 3 4 5 Polygon example In this example we have 6 points three for the outer triangle and three for the inner one We connect each one with two 2 path In plain English each element of a path must correspond to the position of a point defined in the points vector e g 1 refers to 100 0 Notice In order to get a 3D object you either extrude a 2D polygon linear or rotation or directly use the polyhedron primitive solid When using extrusion to form solids its important to realize that the winding direction of the polygon is significant If a polygon is wound in the wrong direction with respect to the axis of rotation the final solid after extrusion may end up invisible This problem can be checked for by flipping the polygon 67 using scale 1 1 assuming that extrusion is being done about the Z axis as it is by default Notice Althought the 2D drawing commands operate in axes labeled as X and Y the extrusion commands implicitly translate these objects in X Z coordinates and rotate about the Z axis Example polygon 0 0 10 90 11 10 convexity N import _dxf DEPRECATED The import dxf module will be removed in future releases Use
93. rder of the points or the order they are referenced in each triangle triple The order of triangles is immaterial Note that if your polygons are not all oriented the same way OpenSCAD will either print an error or crash completely so pay attention to the vertex ordering Again remember that the pN components of the triangles vector are O indexed references to the elements of the points vector Example a square base pyramid po Lyhedron points 10 10 0 10 10 0 10 10 0 10 10 0 the four points at base 0 0 10 J the apex point triangles 0 1 4 1 2 4 2 3 4 3 9 4 each triangle side 1 0 3 2 1 3 two triangles for square base ie A simple polyhedron square based pyramid Ordering of triangle points An example of a more complex polyhedron and showing how to fix polyhedrons with badly oriented polygons When you select Thrown together from the view menu and compile the design not compile and render you will see a preview with the mis oriented polygons highlighted Unfortunately this highlighting is not possible in the OpenCSG preview mode because it would interfere with the way the OpenCSG preview mode is implemented 17 Below you can see the code and the picture of such a problematic polyhedron the bad polygons triangles or compositions of triangles are in pink Bad polyhedron polyhedron points 0 10 60 0 10 60 0 10 0 0 10 0l 60 10 60
94. re than one place e MORE INFO ON HOW TO LOCATE THIS FUNCTION PLEASE e DO SUB DIRECTORIES WITHIN THE LIBRARY PATH WORK Built in Libraries OpenSCAD bundles the MCAD library Other Libraries e BOLTS tries to build a standard part and vitamin library that can be used with OpenSCAD and other CAD tools 1 e Obiscad contains various useful tools notably a framework for attaching modules on other modules in a simple and modular way 2 e This library provides tools to create proper 2D technical drawings of your 3D objects 3 e Stephanie Shaltes wrote a fairly comprehensive fillet library https github com StephS i2 xends blob master inc fillets scad Old content Library Links Here is a collection of shape part libraries that you can use in your OpenSCAD design see the include and use command Shapes by Catarina Mota Contains the following modules Included in the MCAD distro see below A11 these modules are 3D shapes despite some of them having 2D names e box width height depth e roundedBox width height depth radius e cone height radius e oval width height depth e tube height radius wall e ovalTube width height depth wall e hexagon height depth e octagon height depth e dodecagon height depth e hexagram height depth e rightTriangle adjacent opposite depth e equiTriangle side depth e 12ptStar height depth t13 Shapes by Giles Bathgate 2D e t
95. reating computer animated movies OpenSCAD is not an interactive modeller Instead it is something like a 3D interpreter that reads in a script file that describes the object and renders the 3D model from the script file This gives you the designer full control over the modelling process and enables you to easily change any step in the modelling process or even to produce designs that are defined by configurable parameters OpenSCAD provides two main modelling techniques First constructive solid geometry CSG and second extrusion of 2D outlines Autocad DXF files are used as the data exchange format for the 2D outlines In addition to 2D paths for extrusion it is also possible to read design parameters from DXF files In addition to reading DXF files OpenSCAD can also read and create 3D models in the STL and OFF file formats OpenSCAD can be downloaded from http openscad org You may find extra information in the mailing list People who don t want to or can t install new software on their computer may be able to use OpenJSCAD http OpenJSCAD org a port of OpenSCAD that runs in a web browser A pt_BR translation of this document is avaliable on GitHub repository not completed on development 1 First Steps OpenSCAD User Manual First Steps Creating a simple model lt OpenSCAD User Manual First Steps The latest reviewed version was checked on 18 March 2013 There are 4 pending changes awaiting review For our
96. riangle radius e reg polygon sides radius e pentagon radius e hexagon radius e heptagon radius e octagon radius e nonagon radius e decagon radius e hendecagon radius e dodecagon radius 3D e cone height radius center false oval prism height rx ry center false oval tube height rx ry wall center false cylinder tube height radius wall center false e tubify radius wall Tubifies any regular prism e triangle prism height radius e triangle tube height radius wal1 e pentagon prism height radius e pentagon tube height radius wal1 hexagon prism height radius e heptagon prism height radius octagon prism height radius e nonagon prism height radius e decagon prism height radius e hendecagon prism height radius e dodecagon_ prism height radius e torus outerRadius innerRadius triangle pyramid radius e square pyramid width height depth Metric Fasteners by Giles Bathgate All dimensions are proportional to the dia so for example cap bolt 3 15 will produce a M3 cap bolt with a 15mm threaded section e cap bolt dia len e csk bolt dia len e washer dia e flat nut dia e bolt dia len cylinder chamfer rl r2 114 e chamfer len r MCAD library Originally from gsithub com D1plold MCAD The following is taken from the README follow the link for the latest version Currently Provided Tools e involute_ gears sc
97. rmal 2 module doesnt pass it echo normal module normal mod doesnt pass it normal _mod normal 1 Should echo 2 special 3 another 5 module passes it echo special another module special mod Sanother 6 passes it Special mod special 4 Should echo 4 6 So basically it is useful when you do not want to pass many parameters all the time fa fs and fn The fa Sfs and fn special variables control the number of facets used to generate an arc fa is the minimum angle for a fragment Even a huge circle does not have more fragments than 360 divided by this number The default value is 12 i e 30 fragments for a full circle The minimum allowed value is 0 01 Any attempt to set a lower value will cause a warning fs is the minimum size of a fragment Because of this variable very small circles have a smaller number of fragments than specified using fa The default value is 2 The minimum allowed value is 0 01 Any attempt to set a lower value will cause a warning fn is usually 0 When this variable has a value greater than zero the other two variables are ignored and full circle is rendered using this number of fragments The default value is Q When fa and fs are used to determine the number of fragments for a circle then OpenSCAD will never use less than 5 fragments This is the C code that calculates the number of fragments in a circle int get fragments from r double r
98. ry to fetch and install these automatically for you note you must have sudo working for this script to work scripts uni get dependencies sh Now check the version numbers against the openscad README md file to see if the version numbers are high enough and that no packages were accidentally missed OpenSCAD comes with another helper script to assist in this process scripts check dependencies sh Note that this detects a lower bound on GLEW not the actual version you have If your system passes all checks continue to the Building OpenSCAD section below If you are missing libraries try to search your package manager to see if it might have them under different names If your package manager has the package but it is just too old then read the next section on building your own dependencies Building the dependencies yourself On systems that lack updated dependency libraries or tools you can download and build your own As of 2013 OpenSCAD comes with scripts that can do this automatically without interfering with any system libraries and without requiring root access by putting everything under SHOME openscad deps It however will not build X11 Qt4 gcc bash or other basics First set up the environment variables if you don t use bash replace source with a single source scripts setenv unibuild sh Then download and build scripts uni build dependencies sh If you only need CGAL or OpenCSG y
99. s page may need to be reviewed for quality 86 0 OpenSCAD session using emacs as an external editor Contents e Why use an external editor e 2 How to use an external editor e 3 Support of external editors e A Additional benefits Why use an external editor Many people prefer to use a certain editor They are used to the feature set and know the keybindings OpenSCADs editor is functional and simplistic but might lack features people know from other editors How to use an external editor OpenScad is able to check for changes of files and automatically recompile if a file change occurs To use this feature enable Design gt Automatic Reload and Compile Once the feature is activated just load the scad file within OpenSCAD as usual File gt Open After that open the scad file in your favorite editor too Edit and work on the scad file within the external editor Whenever the file is saved to disk from within the external editor OpenSCAD will recognize the file change and automatically recompiles accordingly The internal editor can be hidden by minimizing the frame with the mouse or by selecting View gt Hide editor ST Support of external editors In principle all editors can be used For some exist extensions modes to provide features for OpenSCAD e Emacs OpenSCAD delivers a emacs mode for OpenSCAD files Use the link or the emacs package management ELPA and the emacs marmelade repository e Ka
100. se a program like less search with or wordpad to review the log To debug these errors you must understand basics about Windows linking Windows links to its standard C library with basic C functions like malloc But there are four different ways to do this as follows compiler switch type linked runtime C library MT Multithreaded static Release link to LIBCMT lib MTd Multithreaded static Debug link to LIBCMTD lib MD Multithreaded DLL Release link to MSVCRT lib which itself helps link to the DLL MDd Multithreaded DLL Debug link to MSVCRTD lib which itself helps link to the DLL All of the libraries that are link together in a final executable must be compiled with the same type of linking to the standard C library Otherwise you get link errors like LNK2005 XXX is already defined in YYY But how can you track down which library wasn t linked properly 1 Look at the log and 2 dumpbin exe dumpbin exe dumpbin exe can help you determine what type of linking your lib or obj files were created with For example dumpbin exe all CGAL lib find i DEFAULTLIB will give you a list of DEFAULTLIB symbols inside of CGAL lib Look for LIBCMT LIBCMTD MSVCRT or MSVCRID That will tell you according to the above table whether it was built Static Release Static Debug DLL Release or DLL Debug DLL of course means Dynamic Link Library in this conversation This can help you track down for example l
101. sting note is comparing the 2d and 3d polyhedra and nef polyhedra functions There is no way to transform a 2d nef polyhedron for example so OpenSCAD implemented it s own There is no easy way to convert a Nef polyhedron from 2d to 3d The method for iterating through the 2d data structure is also entirely different from the way you 93 iterate through the 3d data structure one uses an explorer while another provides a bunch of circulators and iterators CGAL is also very slow to compile as a library that is almost entirely headers there is no good way around this other than to get a faster machine with more RAM and possibly to use the clang compiler instead of GCC Paralell building make j can help but that wont speed up the compile of a single file you are working on if it uses a feature like CGAL Minkowski sums CGAL and GMPQ CGAL allows a user to pick a kernel the type of numbers to be used in the underlying data structures Many 3d rendering engines just use floating point numbers but this can be a problem when doing geometry because of roundoff errors CGAL offers other kernels and number types for example the GMPQ number type from the GNU GMP project This is basically the set of Rational Numbers Rational Numbers the ratio of two integers are an advantage in Geometry because you can do alot of things to them without any rounding error including scaling For example take the number 1 3 You
102. t module but BOTH will display 9 Ze because it is the FINAL calculated value inside the module ECHO 9 ECHO 9 Even though the test module calculated value changes for p those values remained inside the module Those values did not continue outside the test module The program has now finished test 5 and moves to the next command echo p The call echo p would normally display the original value of p 4 Remember that the program will only show the FINAL values It is the next set of commands that produce the final values which is ECHO 6 wy p 6 test 8 echo p We now see p 6 which is a change from earlier We step to the next command test 8 which calls the test module Again the test module calculates two values for p but the program will ONLY display the final value There will be two executions of echo p inside test module but BOTH will display 12 because it is the FINAL compiled value that was calculated inside the module Therefore both echo p statements will show the final value of 12 Remember that the test module final values for p will remain inside the module They do not continue outside the test module ECHO 12 ECHO 12 The program has now finished test 8 and moves to the next command echo p Remember at compile that the pgm will show the FINAL values The first value of echo p would have showe
103. t s If it is there then you can probably just rename the file and have it work move CGAL vc90 mt lib CGAL vc90 mt s lib Visual Studio build You can build CGAL using the GUI of visual studio as an alternative to nmake You have to use an alternate cmake syntax Type cmake by itself and it will give you a list of generators that are valid for your machine for example Visual Studio Express is cmake G Visual Studio 9 2008 That should get you a working sln solution file Then run this vcexpress CGAL slkn Modify the build configure target to Release not Debug and change the properties of the projects to be MT multithreaded static builds This is the similar procedure used to build OpenCSG so refer to those instructions above for more detail Note for Unix users The MingW Shell Start Programs provide tools like bash sed grep vi tar amp c The C drive is under c MingW has packages for example mingw get install msys unzip downloads and installs the unzip program Git contains some programs by default like perl The windows command shell has cut paste hit alt space You can also change the scrollback buffer settings References e Windows Building OpenSCAD mailing list 2011 May e C Run Time Libraries linking Microsoft com for Visual Studio 8 The older manual is good too here e old nabble on isatty flex e Windows vs Unix Linking dynamic load modules by Chris Phoenix e St
104. te nerd256 provides a kate syntax file for OpenSCAD See Instructions tab in Thingiverse to install it You could create also a kate External tool to open OpenSCAD with the current file with script openscad directory filename e VIM vim org provides a VIM syntax file for OpenSCAD Also a dictionary file is here Additional benefits Beside of using an external editor of choice this solutions enables the flexible usage of multi monitor set ups One can have one monitor set up to depict the 3D object on the entire screen and a second monitor for the editor and other tools OpenSCAD User Manual Using OpenSCAD in a command line environment lt OQpenSCAD User Manual This page may need to be reviewed for quality OpenSCAD can not only be used as a GUI but also handles command line arguments Its usage line says OpenSCAD 2013 05 has these options openscad o output file d deps file m make command D var val render camera translatex y z rotx y z dist camera eyex y z centerx y z imgsize width height projection 0 rtho p ersp filename Earlier releases had only these openscad o output file d deps file m make command D var val filename The usage on OpenSCAD version 2011 09 30 now deprecated was Openscad s stl file o off file x dxf file d deps file m make command D var val filename Contents e E
105. this is very helpful for a program like CGAL that is dealing with lots of intersections between planes Imagine doing an interesection between two faceted spheres offset by their radius for example The downside is that Rationals are slow Most of the optimization made in the hardware of modern computer CPUs is based around the idea of dealing with ordinary floating point or integer numbers not with ratios of integers integers which can be larger than the size of long int on the machine also called Big Ints When doing debugging if you are inside the code and you do something like std cout lt lt vertex gt pointQ xQ you will get a ratio of two integers not a floating point For floating conversion you have to use CGAL to_ double vertex gt pointQ xQ You may notice sometimes that your double conversion with its chopping off and rounding it might show that two points are equal when printing the underlying GMPQ will show that in fact the same two points have different coordinates entirely Lastly within OpenSCAD it must be noted that it s default number type is typically C double floating point Thus even though you may have perfect CGAL objects represented with rationals OpenSCAD itself uses a lot of floating point and translates the floating point back and forth to CGAL GMPQ during compilation another area for slowdown 94 Links e CGAL s main website e Number represenatio
106. time it tries to access a missing file Makefile example The d and m options only make sense together m without d would not consider modified dependencies when building exports d without m would require the files to be already built for the first run that generates the dependencies Here is an example of a basic Makefile that creates an stl file from an scad file of the same name explicit wildcard expansion suppresses errors when no files are found include wildcard deps stl Scad openscad m make o d deps lt When make my example stl is run for the first time it finds no deps files and will just depend on my example scad since my example stl is not yet preset it will be created unconditionally If OpenSCAD finds missing files it will call make to build them and it will list all used files in my example stl deps When make my example stl is called subsequently it will find and include my example stl deps and check if any of the files listed there including my example scad changed since my example Stl was built based on their time stamps Only if that is the case it will build my example stl again Automatic targets When building similar stl files from a single scad file there is a way to automate that too match module foobar make me TARGETS shell sed module a z0 9 make me d s module s stl base scad all TARGETS auto generated
107. tion nsh macro from http nsis sourceforge net File Association in the NSIS Include directory C Program Files NSIS Include e Run git submodule init and git submodule update to download the MCAD system https github com elmom MCAD into the openscad libraries folder e Copy the OpenSCAD libraries and examples directory into the release directory e Copy OpenSCAD s scripts installer nsi to the release directory e Right click on the file and compile it with NSIS It will spit out a nice easy installer Enjoy Compiling the regression tests e Follow all the above steps build openscad run it and test that it basically works e Install Python 2 x not 3 x from http www python org e Install Imagemagick from http www imagemagick org e read openscad docs testing txt e Go into your QT shell 109 set PATH PATH C Python27 or your version of python cd c openscad tests cmake DCMAKE BUILD TYPE Release Edit the CMakeCache txt file search replace MD to MT cmake nmake f Makefile e This should produce a number of test exe files in your directory Now run ctest If you have link problems see Troubleshooting below Troubleshooting Linker errors If you have errors during linking the first step is to improve debug logging and redirect to a file Open Openscad pro and uncomment this line QMAKE LFLAGS VERBOSE Now rerun nmake f Makefile Release gt log txt You can u
108. tively Show Crosshairs Ctr1 3 If Show Crosshairs is enabled the center of the viewport will be indicated by four lines pointing in the room diagonal directions of the global coordinate system This is useful when aligning the viewing area to a particular point in the model to keep it centered on screen during rotation Animation The Animate option adds an animation bar to the lower edge of the screen As soon as FPS and Steps are set reasonable values to begin with are 10 and 100 respectively the current Time is incremented by 1 Steps FPS times per second until it reaches 1 when it wraps back to U Every time Time is changed the program is re evaluated with the variable t set to the current time Read more about how t is used in section Other_Language Features View alignment The menu items Top Bottom Diagonal and Center Ctri 4 Ctri 5 Ctri 0 Ctr1 P align the view to the global coordinate system 10 Top Bottom Left Right Front and Back align it in parallel to the axes the Diagonal option aligns it diagonally as it is aligned when OpenSCAD starts The Center option will put the coordinate center in the middle of the screen but not rotate the view By default the view is in Perspective mode meaning that distances far away from the viewer will look shorter as it is common with eyes or cameras When the view mode is changed to Orthogonal visible distances will not depend on the camera distance
109. turns the euclidean norm of a vector Note this returns is the actual numeric length while len returns the number of elements in the vector or array Usage examples a 1 2 3 4 b abcd c d Ts e 1 2 3 4 1 2 3 1 2 1 echo norm a 5 47723 echo norm b undef echo norm c 0 echo norm d undef echo norm e 0 5 47723 echo norm e 1 3 74166 echo norm e 2 2 23607 echo norm e 3 1 Results ECHO 5 47723 ECHO undef ECHO 0 ECHO undef ECHO 5 47723 ECHO 3 74166 ECHO 2 23607 ECHO 1 pow Mathematical power function Parameters lt base gt Decimal Base lt exponent gt Decimal Exponent Usage examples for 1 0 5 translate 1 25 0 0 cylinder h pow 2 i 5 r 10 echo i pow 2 i echo pow 10 2 means 10 2 or 10 10 395 result ECHO 100 echo pow 10 3 means 10 3 or 10 10 10 result ECHO 1000 rands Random number generator Generates a constant vector of pseudo random numbers much like an array When generating only one number you still call it with variable 0 Parameters min value Minimum value of random number range max value Maximum value of random number range value count Number of random numbers to return as a vector seed value optional Seed value for random number generator for repeatable results Usage Examples get a single number Single rand rands 0 10 1 0 echo single rand
110. umber operators take a vector and a number as operands and produce a new vector multiply all vector elements by number divide all vector elements by number Vector Operators The vector operators take vectors as operands and produce a new vector add element wise subtract element wise The can also be used as prefix operator to element wise negate a vector Vector Dot Product Operator The vector dot product operator takes two vectors as operands and produces a scalar sum of vector element products Matrix Multiplication Multiplying a matrix by a vector vector by matrix and matrix by matrix matrix vector multiplication mo Mathematical Functions D The text in its current form is incomplete Trigonometric Functions COS Mathematical cosine function of degrees See Cosine Parameters lt degrees gt Zo Decimal Angle in degrees Usage Example for i 0 36 trans late 1 10 0 0 cylinder r 5 h cos i 10 50 60 OpenSCAD Cos Function sin Mathematical sine function See Sine Parameters lt degrees gt Decimal Angle in degrees Usage example 1 for i 0 5 echo 360 i 6 sin 360 i 6 80 cos 360 i 6 80 trans late sin 360 i 6 80 cos 360 i 6 80 cylinder h 200 r 10 Usage example 2 for i 0 36 trans late 1 10 0 0 cylinder r 5 h sin i 10 50 60 EI OpenSCAD Sin Function tan Mathematical tangent function See Tangent Parameters
111. unction returns not _useful output Function returns undef Output Variable a is undef Variable a is tested undefined Function returns undef Numeric A variable could be a numerical value integer float Vectors Variables can be grouped together into Vectors by using brackets Vectors are useful when dealing with X Y and Z coordinates or sizes Example deck 64 89 18 Cube deck Output A cube with the sizes X 64 Y 89 Z 18 Vectors selection You can also refer to individual values in a vector with vector number number starts from O Example deck 64 89 18 translate 0 0 deck 2 cube deck Output The same cube as the previous example would be raised by 18 on the Z axis since vector indices are numbered 0 1 2 for X Y Z respectively Matrix A matrix is a vector of vectors Example mr cos angle sin angle sin angle cos angle I Output Define a 2D rotation matrix Strings Explicit double quotes or backslashes need to be escaped and respectively Other escaped special characters are newlines n tabs t and carriage returns r NB This behavior is new since OpenSCAD 2011 04 You can upgrade old files using the following sed command sed S non escaped scad gt escaped scad Example echo The quick brown fox tjumps over the lazy dog rThe quick brown fox nThe lazy dog Output 2l ECHO The quick br
112. usion D The text in its current form is incomplete It is possible to use extrusion commands to convert 2D objects to 3D objects This can be done with the built in 2D primitives like squares and circles but also with arbitrary polygons Linear Extrude Linear Extrusion is a modeling operation that takes a 2D polygon as input and extends it in the third dimension This way a 3D shape is created Usage linear extrude height fanwidth center true convexity 10 twist fanrot slices 20 scale 1 0 You must use parameter names due to a backward compatibility issue If the extrusion fails for a non trival 2D shape try setting the convexity parameter the default is not 10 but 10 is a good value to try See explanation further down Twist Twist is the number of degrees of through which the shape is extruded Setting the parameter twist 860 will extrude through one revolution The twist direction follows the left hand rule 0 of Twist linear extrude height 10 center true convexity 10 twist 0 translate 2 0 0 circle r 1 ol 100 of Twist Linear extrude height 10 center true convexity 10 twist 100 translate 2 0 0 circle r 1 100 of Twist linear extrude height 10 center true convexity 10 twist 100 translate 2 0 0 circle r 1 72 500 of Twist linear extrude height 10 center true convexity 10 twist 5
113. utodesk in the 1980s DXFData is sort of the equivalent of PolySet for 2d objects glue between various other 2d representations CGAL Nef Polyhedron This class encapsulates both 2d and 3d Nef polyhedrons It contains useful functions like the boolean operators union intersection and even Minkowski sum It is incredibly slow to compile mostly due to the CGAL minkowski header code being very large so it has been broken into separate cc files You may also note that pointers are generally avoided when dealing with Nef polyhedra instead boost shared ptr is used CGAL ordinary polyhedron You may notice there is no class for ordinary CGAL Polyhedron That s correct There isn t it s always just used as is typically as an intermediate form between other formats As noted the conversion to from ordinary can cause issues for non 2 manifold objects CGAL s Polyhedron also is used for file export see export cc GUI vs tests As of early 2013 OpenSCAD used two separate build systems one for the GUI binary and another for regression testing The first is based on Qmake and the second on Cmake Adding features may require someone to work with both of these systems See doc testing txt for more info on building and running the regression tests Library notes QT OpenSCAD s GUI uses the QI toolkit However for all non gui code the developers avoid QI and use alternatives like boost filesystem This helps with certa
114. v unibuild sh NetBSD 5 x requires a patched version of CGAL It is recommended to upgrade to NetBSD 6 instead as it has all dependencies available from pkgin NetBSD also requires the X Sets to be installed when the system was created or added later On OpenBSD it may fail to build after running out of RAM OpenSCAD requires at least 1 Gigabyte to build with GCC You may have need to be a user with staff level access or otherwise alter required system parameters The dependency build sequence has also not been ported to OpenBSD so you will have to rely on the standard OpenBSD system package tools in other words you have to have root Test suite problems Headless server The test suite will try to automatically detect if you have an X11 DISPLAY environment variable set If not it will try to automatically start Xvfb or Xvnc virtual X framebuffers if they are available If you want to run these servers manually you can attempt the following Xvfb 5 screen 0 800x600x24 amp DISPLAY 5 ctest Alternatively xvfb run server args screen 0 800x600x24 ctest There are some cases where Xvfb Xvnc won t work Some older versions of Xvfb may fail and crash without warning Sometimes Xvfb Xvnc have been built without GLX OpenGL support and OpenSCAD won t be able to generate any images Image based tests takes a long time they fail and the log says return 11 Imagemagick may have crashed while comparing the ex
115. ventually it is planned to move in this direction as the BSDs not to mention OSX are moving towards favoring clang as their main compiler OpenSCAD User Manual Cross compiling for Windows on Linux or Mac OS X lt OpenSCAD User Manual OpenSCAD includes convenience scripts to cross build Windows installer binaries using the MXE system http mxe cc If you wish to use them you can first install the MXE Requirements such as cmake perl scons using your system s package manager click to view a complete list of requirements Then you can perform the following commands to download OpenSCAD source and build a windows installer git clone https github com openscad openscad git cd openscad source scripts setenv mingw xbuild sh scripts mingw x build dependencies sh scripts release common sh mingw32 The x build dependencies process takes several hours mostly to cross build QT It also requires several gigabytes of disk space If you have multiple CPUs you can speed up things by running export NUMCPU x before running the dependency build script By default it builds the dependencies in SHOME openscad_ deps mxe You can override the mxe installation path by setting the BASEDIR environment variable before running the scripts The OpenSCAD binaries are built into a separate build path openscad mingw32 Note that if you want to then build linux binaries you should log out of your shell and log back in The setenv scripts
116. was checked on 2 August 2012 There is 1 pending change awaiting review This is a set of instructions for building OpenSCAD with the Microsoft Visual C compilers The build is as static as reasonable with no external DLL dependencies that are not shipped with Windows Note It was last tested on the Dec 2011 build Newer checkouts of OpenSCAD may not build correctly or require extensive modification to compile under MSVC OpenSCAD releases of 2012 were typically cross compiled from linux using the Mingw amp MXE system See Cross compiling for Windows on Linux or Mac OS xX Contents e Downloads e 2 Installing e 3 Compiling Dependencies e 3 1 Qt e 3 2 CGAL e 3 3 OpenCSG e 3 4 OpenSCAD e 4 Building an installer e 5 Compiling the regression tests e 6 Troubleshooting e 6 1 CGAL e 6 2 References Downloads start by downloading e Visual Studio Express http download microsoft com download E 8 E E8EEB394 7F42 4963 A2D8 29559B738298 VS20 105 O8ExpressWithSP1ENUX1504728 iso QT for vs2008 http https sourceforge net pro jects glew files glew 1 5 8 glew 1 5 8 win32 zip download cmake http www cmake org files v2 8 cmake 2 8 4 win32 x amp 6 exe boost http www boostpro com download boost 1 46 1 setup exe cgal https gforge inria fr frs download php 27647 CGAL 3 7 Setup exe OpenCSG http www opencsg org OpenCSG 1 3 2 tar gz eigen2 http bitbucket org eigen eigen get 2 0 15 zip emp mpfr http ho
117. xport options 88 e 1 1 Camera and image output e 2 Constants e 3 Command to build required files e 4 Makefile example e 4 1 Automatic targets e 5 Windows notes Export options When called with the 0O option OpenSCAD will not start the GUI but execute the given file and export the to the output file in a format depending on the extension stl off dxf csg Some versions use s d o to determine the output file format instead check with openscad help If the option d is given in addition to an export command all files accessed while building the mesh are written in the argument of d in the syntax of a Makefile Camera and image output For 2013 05 the option to output a png image was added There are two types of cameras available for the generation of images The first camera type is a gimbal camera that uses Euler angles translation and a camera distance like OpenSCAD s GUI viewport display at the bottom of the OpenSCAD window 1 There is a bug in the implementation of cmdline camera where the rotations do not match the numbers in the GUI This will be fixed in an upcoming release so that the GUI and cmdline camera variables will work identically The second camera type is a vector camera with an eye camera location vector and a lookat center vector imgsize chooses the png dimensions and projection chooses orthogonal or perspective as in the GUI By default cmdline png

Download Pdf Manuals

image

Related Search

Related Contents

AEG B.150  DeLonghi ESAM 3200.S    Téléchargez le Mémoire sous format PDF  Bedienungsanleitung Lightweight Schlauchreifen  Pre-Release Software License Agreement  05 - Les campagnols ( DRAAF / FREDONCA )  

Copyright © All rights reserved.
Failed to retrieve file