-
Notifications
You must be signed in to change notification settings - Fork 0
Transformations
-
translate*element modified*Moves an element by name a specified displacement in X,Y,Z directions.e.g.
$scad->cube("bodyTop",[30,20,10],1)->translate("bodyTop",[0,0,5])The first parameter is the name of the element (the element must exist already).The second parameter is an arrayref of three elements defining displacement. -
scale*element modified*Scales an element by name by specified ratios in X,Y,Z directions.e.g.
$scad->cube("bodyTop",[30,20,10],1)->scale("bodyTop",[1,2,0.5]). The first parameter is the name of the element (the element must exist already). The second parameter is an arrayref of three scale factors. -
resize*element modified*Resizes an element by name to specified dimensions in X,Y,Z directions.e.g.
$scad->cube("bodyTop",[30,20,10],1)->resize("bodyTop",[30,40,5]);. The first parameter is the name of the element (the element must exist already). The second parameter is an arrayref of three new dimensions. -
rotate*element modified*Rotates an element by name around in X,Y,Z axes.e.g.
$scad->cylinder("wheel",{h=>2,r=>8},1)->rotate("wheel",[90,0,0]);. The first parameter is the name of the element (the element must exist already).The second parameter is an arrayref of three rotations in degrees. -
hull*new element created*Generates the convex hull of child nodes. Effectively lofts between two (or more) objects. The example below draws randomly placed cubes and then draws a hull connecting them between consecutive pairs of cubes. The first parameter is the name of the new element created, the second parameter refers to the item that all other elements are subtracted from.
my $chart=new OpenSCAD; my $pos=[0,0,0]; my @cubes=(); my @hulls=(); for (0..100){ # a hundred randomly displaced cubes $chart->cube("dot$_",3)->translate("dot$_",$pos); $pos=[$pos->[0]+((-20..20)[rand()*40]),$pos->[1]+((-20..20)[rand()*40]),$pos->[2]+((-20..20)[rand()*40])]; push @cubes,"dot$_"; } for (0..100){ # hulls between sequential pairs $chart->hull("hull$_",$cubes[$_],$cubes[$_-1]); push @hulls,"hull$_"; } $chart->build(@hulls)->save("hull"); -
offsetOffset generates a new 2d interior or exterior outline from an existing outline. There are two modes of operation: radial and delta.
-
multimatrixMultiplies the geometry of all child elements with the given affine transformation matrix, where the matrix is 4 x 3, or a 4 x 4 matrix with the 4th row always forced to [0,0,0,1].
-
union*new element created*Implicitly joins multiple elements into one element.e.g.
$scad->union("wheel",qw/wheel nut nut1 nut2 nut3/);the first item is the name of the new element created, the following elements are elements to be joined together. If an element with the name of the first parameter does not exist, it is created, otherwise it is over-written. -
difference*new element created*Subtracts one or more elements from one element and creates a new element.e.g.
$scad->difference("wheel",qw/wheel nut nut1 nut2 nut3/);The first parameter"wheel"in this example is the name of the new element created, the second parameter refers to the item that all other elements are subtracted from. If an element with the name of the first parameter does not exist, it is created, otherwise it is over-written.So this statement takes the item "wheel" (the scendond parameter), subtracts all the nuts, and overwrites the code in "wheel"(first parameter). -
intersection*new element created*creates an element representing the overlapping parts of 2 or more elements and creates a new element.e.g.
$scad->intersection("overlap",qw/item1 item2 item3/);The first parameter is the name of the new element created, the other names refer to elements which overlap neach other.