render()
Adding render() before a code block forces OpenSCAD to render and cache the mesh produced by that code, making each successive render much faster.
An Example
The following OpenSCAD program was a dissection of member Emmett Lalish's file Rhombic Dodecahedra Chain.
Adding render() before a code block forces OpenSCAD to render and cache the mesh produced by that code, making each successive render much faster.
An Example
The following OpenSCAD program was a dissection of member Emmett Lalish's file Rhombic Dodecahedra Chain.
- Starting with the following shapes where L= the height of the module and in this case 40:
translate ([-60,0,0])rotate([0,0,45])cube(L*[1,1,2],center=true); translate ([0,0,0])rotate([0,45,0])cube(L*[1,2,1],center=true); translate ([70,0,0])rotate([45,0,0])cube(L*[2,1,1],center=true);
- Combine each shape by using intersection(). The shape created will be just where the three shapes intersect:
intersection(){ rotate([0,0,45])cube(L*[1/s,1/s,2],center=true); rotate([0,45,0])cube(L*[s,2,s],center=true); rotate([45,0,0])cube(L*[2,s,s],center=true); }
- Now you want to create another form using these shapes.
Here L is still 40, and s=fraction of the face to hollow/2+0.5translate([-70,0,0])rotate([0,0,45])cube(L*[1/s,1/s,2],center=true); translate([20,0,0])rotate([0,45,0])cube(L*[s,2,s],center=true); translate([100,0,0])rotate([45,0,0])cube(L*[2,s,s],center=true);
- Combine each shape again by using intersection(). The shape created will be just where the three shapes intersect:
intersection(){ rotate([0,0,45])cube(L*[1/s,1/s,2],center=true); rotate([0,45,0])cube(L*[s,2,s],center=true); rotate([45,0,0])cube(L*[2,s,s],center=true); }
- You should now have two shapes:
The next thing to do is create a boolean difference of the second form from the first form:
- The next step is the continue differencing from the initial form. This time you will rotate the second form 90° on the X axis:
- The last step is to create another difference from the initial form. This time rotate the second form 90° on the Y axis:
- If you wanted to see how the form falls on the platform, you could add a cube:
%cube([220,140,1],center=true);
- Rotating the form by 45° on the X axis and 90° on the Z axis will straighten the form:
rotate([45,0,90])
- Now to raise the form to sit on the platform:
rotate([45,0,90])
- Surround the code with
render(){ }
- Then put it in a module:
module openRhom(){ render(){ translate([0,0,L/2]) rotate([45,0,90]) difference(){ firstShape(); secondShape(); rotate([90,0,0])secondShape(); rotate([0,90,0])secondShape(); } } }
- Now you can quickly preview chains. Here set a variable d to be the 16.5:
chain(20); module chain(n){ translate([-(n-1)*1*d+d,0,0]) for(i=[1:n]){ translate([(i-1)*2*d,0,0]) openRhom(); } }