OpenSCAD: Difference between revisions

Created page with "OpenSCAD is a declarative 3d modeling program. Objects are defined in terms of basic 2D and 3D shapes, and a set of operators is provided to manipulate these objects. It can generate STL files from the command line. ==Basic shapes== * Square (rectangle), circle, polygon * Cube (rectangular prism), sphere, cylinder, polyhedron <tt>circle</tt> and <tt>cylinder</tt> are approximated using the <tt>fn</tt> system variable. Low values of <tt>fn</tt> can be used to generate r..."
 
No edit summary
Line 8: Line 8:


A 2D shape can be converted into a 3D one using <tt>linear_extrude</tt> or <tt>rotate_extrude()</tt>.
A 2D shape can be converted into a 3D one using <tt>linear_extrude</tt> or <tt>rotate_extrude()</tt>.
==<tt>use</tt> vs <tt>include</tt>==
A SCAD file can include other SCAD files with either the <tt>include</tt> or <tt>use</tt> keywords. <tt>include</tt> statements are replaced with the body of the <tt>include</tt>d file (any <tt>include</tt>s or <tt>use</tt>s within the file are expanded). <tt>use</tt> only lifts <tt>module</tt>s and <tt>function</tt>s, and only affects the current file (i.e. recursive <tt>use</tt>s do not escape beyond the file that <tt>use</tt>s them).
It's useful to have a file draw its various modules, so that running it at the top level generates examples etc. Such a file can be imported with <tt>use</tt>, and these examples won't be drawn.
These cannot be used within a <tt>module</tt> or <tt>function</tt>.