To move an object, you can simply use the translate() method:
fromopenscadimport*# Create two cubesc1=cube([5,5,5])c2=cube([3,3,10])# Translate the cube by 7 units upc2=c2.translate([0,0,7])# Display the resultresult=c1|c2output(result)
// Create the first cubecube([5,5,5]);// Create the second cube, and apply// a translation of 7 units uptranslate([0,0,7])cube([3,3,10]);
Notice how we assign the result of the translate() method back into c2.
This is because just like the union() and difference() methods we saw earlier, this method return a brand new object.
Another option to position an object is to rotate it. You can do that with the 'rotate()' method.
fromopenscadimport*# Create a cubec=cube([5,5,5])rotated=c.rotate([10,0,-30])# rotate 10 degrees around X axis, not in Y and -30 around Z axis finallyoutput(rotated)
// rotate 10 degrees around X axis, not in Y and -30 around Z axis finallyrotate([10,0,-30])cube([5,5,5]);
One advantage of python language over the OpenSCAD is that you specify the build processes in several
tiny steps without having to use hierarchy
Lets now spot the tiny differences between openSCAD and python here.