Graphics Reference
In-Depth Information
cylinder(h=ringHeight,r=(ringSize+1)/2+ringThickness,center=true);
// inside of ring
cylinder(h=ringHeight+10,r=(ringSize+1)/2,center=true);
}
Compile the code
Compile your code and note the changes. Try changing the value for
ringSize , ringThickness , and ringHeight to different numbers, recom-
pile, and see the model change accordingly.
Now you can adjust the value of ringSize and/or ringHeight and re-compile
the program. Your model will automatically resize! Behold the power of fully
parametric models!
Now that you have a working fully parametric model, you can make our ring
more interesting by removing some decorative rectangular elements from it
to create cutouts in the ring band. You will use another geometric solid, the
cube, which can also be used to create rectangular shapes.
Create a rectangle
To create a rectangular box, you need to provide a 3 value array. You will
add this to your code in a few steps:
cube([4, 3.5, 30]); // in x,y,z order
Note that you cannot use the “property equals” (example:
“h=20”) convention for cubes. You must supply three num-
bers in width, height, length order.
Why is it a three-value array and not width, height, and length?
Because we are moving models around in 3 dimensional
space, the OpenSCAD language is written to specify coordi-
nates. Using the terms “width”, “height”, and “length” regard-
ing a box that is being rotated in 3D space can get confusing,
so instead OpenSCAD uses the x,y,z point naming convention
to specify rectangular “cubes”.
Using center with cubes
Cubes also have another property that we can use, center . By default, a
cube is placed with its corner at the origin in the x,y,z planes.
However, you can specify that the cube should be centered at the origin,
by setting “center” to true:
cube([4, 3.5, 30]),center=true); // in x,y,z order
Subtract cubes from the ring shape
Next you will create square cutouts from the ring band to make it more
decorative, as shown in Figure C-6 . You will use what you have learned
so far, plus the rotate command.
 
Search WWH ::




Custom Search