-
Notifications
You must be signed in to change notification settings - Fork 25
rod(size, h, d, r, orientation=z, anchor=$inward)
rod
is intended as a replacement for the cylinder
module.
parameters h
, d
, and r
are equivalent to their counterparts within the cylinder
module. Cylinder also offers an additional parameter, size
that operates much like the size
parameter of the box
module - size.x
and size.y
define diameters along the x and y axes, and size.z
defines the height. This is done in order to standardize parameters across the relativity.scad primitives.
Parameters d1
, d2
, r1
, and r2
are not supported by the rod
module as they do not interact well with the align
module. Future versions may change this, however.
rod
offers all the existing functionality of cylinder
, but unlike cylinder, rod
renders any child module passed to it:
rod(d=10,h=10)
sphere(d=15);
By default, child modules will render with their origins at the center of their parent module. This can be changed using standard built-in modules like transform
. rod
exposes a special variable, $parent_size
, that allows translation relative to the size of the parent. $parent_size.x
and $parent_size.y
expose the x and y diameters and $parent_size.z
exposes the height.
rod(d=10,h=10)
translate([0,0,$parent_size.x/2])
sphere(d=15);
relativity.scad also offers a wrapper for the translate
module, called align
. Statements such as the one above can be streamlined using the align
module:
rod(d=10,h=10)
align([0,0,1])
sphere(d=15);
rod
also streamlines its own translation. Consider a statement such as this:
cylinder_height = 10;
translate([0,0,cylinder_height/2])
cylinder(d=10, h=cylinder_height, center=true);
rod
offers a parameter, anchor
, that defines where you want the origin to be relative to rod
. The statement above is equivalent to the following:
rod(d=10,h=10, anchor=[0,0,-1]);
anchor
acts as a complete replacement for the center
parameter exposed by cylinder
. The following statements are equivalent:
rod(d=10,h=10, anchor=[0,0,0]);
cylinder(d=10,h=10, center=true);
rod(d=10,h=10, anchor=[0,0,-1]);
cylinder(d=10,h=10, center=false);