This article’s goal is to explain how to use a parametric file with OpenScad, to produce a made-to-measure object.
A parametric file is a “flexible” 3D model. SCAD format is based on CSG modeling. It provides the user ability to use parameters, and to choose which values are associated with each of them.
Highly Configurable Wheel
File created by Alex Franke – CodeCreations
You can download it here : http://www.thingiverse.com/thing:21486
This is how a file looks like in OpenSCAD :
File created by Charliearmorycom
You can download it here : http://www.thingiverse.com/thing:54024
Interface is divided into 2 zones :
– Editor (left side)
– Viewing area (right side)
- left click = 3D view
- right click = Pan
- scroll wheel = Zoom
Orthogonal views (top, bottom, side …)
Settings (black) and their values (red) :
3/ PARAMETERS, VALUES AND COMMENTS
A parameter and its value are written like this:
parameter = value ;
Comments are small texts to help the user, preceded by // , or enclosed between /* and */ .
Here is the effect of a change of values for the parameters “Knob Height” and “KnobDiameter” (knob’s height and diameter, in mm):
At first, the knob was “20” mm height for “20” mm width. By simply changing these values by the numbers “15” and “100”, we obtained a 15mm height knob, for 100mm width.
3/ VIEWING CHANGES : PREVIEW
After changing something in the code editor, you must tell OpenScad that you want to generate a preview by typing F5 (in order to “recalculate” the model).
TO SEE YOUR CHANGES:
OR THIS BUTTON :
4/ OTHER TYPES OF VALUES
Numeric values that express dimensions are the most common, but there are others, such as “Boolean” values. A Boolean value has only two possibilities: either it is 1 (or TRUE), or it is 0 (or FALSE). Typically, Boolean values are used to provide a binary choice (YES / NO).
Parametric Lego Brick
File created by Andrew Sweet
You can download it here : http://www.thingiverse.com/thing:231651) :
There are also values to offer a choice between several options. These can be numeric values like “1, 2, 3, 4 …”.
Customizable Furniture Minis
File created by mathgrrl
You can download it here : http://www.thingiverse.com/thing:332507) :
This type of values can also be expressed “literary” :
The parameter then takes a value as a “word”. In this case, the value must be enclosed between quotation marks. The possible options are usually written in the comments.
6/ GET A PRINTABLE STL FILE : RENDER AND EXPORT
TO RENDER (MANDATORY BEFORE EXPORTING STL)
OR THIS BUTTON :
TO EXPORT THE 3D FILE TO STL FORMAT
PRESS THIS BUTTON:
Or via the menu bar : Design / Compile and Render.
The STL file can then be printed, as the rotary knob seen above:
And once installed on the LCD controller of my 3D printer: