In Which OpenSCAD Wins Me Over

I want to be clear about one thing: when it comes to 3D, it’s hard to win praise from me. AOI is probably a pretty good 3D program, given how many people use it successfully to do great things, as is Google Sketchup. However, the warmest praise I can be recorded giving either of them is “we need lots of different points of view!” (Okay, there was that one time I admitted Google Sketchup was better for scribing things onto surfaces. But still.)
I say this so you will understand what I mean when I say: OpenSCAD is a game changer.
The above shape, which in any mesh-based modeler would be a tedious chore of plucking verts around and stitching blocks and deleting and creating faces, is a lark in OpenSCAD. Seriously, here’s the code for it:

Not only is that practically nothing in terms of file length, it was easy to put together. And the tear drop? Permanently available as a library now. TearDrop() is portable to anything I might want a reprap-style hole in, scalable to fit any blot or rod, translatable to anywhere on a design, replicable to any number of copies.
And OpenSCAD has for loops.
I dragged the above into Blender to get a real close look at the mesh, not sure whether to believe that the mesh could have come out clean, but found no errors. There are cosmetic issues (mesh cosmetics: lots of thin triangles and a few tiny protrusions, yes, I’m PICKY) but what matters for nearly every possible scenario is that it be manifold, and it was. I’ve tested a few corner cases like two planes intersecting at exactly their endpoints, and they come through clean. OpenSCAD marks the beginning of really usable open-source CSG. Which is a very big deal: there are wide classes of problems that are brutal on a mesher but trivial in CSG.

Andres Said,
November 6, 2009 @ 1:03 pm
It gets better, the teardrop module itself can get parametric, this isn’t entirely so, but some quick changes and putting holes of various sizes, pretty easy.
module TearDrop(radius)
{
union(){
cylinder(h=200,r=radius, center = true);
intersection(){
rotate(45,[0 0 1]) scale([1 1 20]) cube(size = 2*radius, center = true);
translate([1.75*radius, 0, 0]) scale([1 1 20]) cube(size = 2*radius, center = true);
}
}
}
difference(){
cube([50 300 100], center = true);
translate([0 -100 0]) rotate(-90, [0 1 0]) TearDrop(10);
rotate(-90, [0 1 0])TearDrop(20);
translate([0 100 0]) rotate(-90, [0 1 0])TearDrop(30);
}
hope that comes out.
Allan Ecker Said,
November 6, 2009 @ 1:11 pm
Wasn’t sure about argument passing since I hadn’t tested it, but that’s another big thing: generating a TearDrop of any size.
With this CSG program we can parametrize everything.
Revar Said,
November 6, 2009 @ 3:03 pm
Sadly, I wasn’t able to get module recursion to work, so I wonder if it’s just not implemented yet, or if I need forward module declarations. I was able to implement a limited simple Sierpinski tetrahedra sponge to five levels, but I should have been able to do it in far less code!
module tetra(rad=10) {
sval = rad*sin(60);
cval = rad*cos(60);
pt1 = [sval, -cval, -cval-rad];
pt2 = [0, rad, -cval-rad];
pt3 = [-sval, -cval, -cval-rad];
pt4 = [0, 0, 0];
polyhedron(
points = [pt1,pt2,pt3,pt4],
triangles = [
[0, 1, 2],
[3, 1, 0],
[3, 2, 1],
[0,2,3]
]
);
}
module sier1(rad) {
rad = rad / 2;
sval = rad*sin(60);
cval = rad*cos(60);
tetra(rad);
translate([sval,-cval,-cval-rad]) tetra(rad);
translate([-sval,-cval,-cval-rad]) tetra(rad);
translate([0,rad,-cval-rad]) tetra(rad);
}
module sier2(rad) {
rad = rad / 2;
sval = rad*sin(60);
cval = rad*cos(60);
sier1(rad);
translate([sval,-cval,-cval-rad]) sier1(rad);
translate([-sval,-cval,-cval-rad]) sier1(rad);
translate([0,rad,-cval-rad]) sier1(rad);
}
module sier3(rad) {
rad = rad / 2;
sval = rad*sin(60);
cval = rad*cos(60);
sier2(rad);
translate([sval,-cval,-cval-rad]) sier2(rad);
translate([-sval,-cval,-cval-rad]) sier2(rad);
translate([0,rad,-cval-rad]) sier2(rad);
}
module sier4(rad) {
rad = rad / 2;
sval = rad*sin(60);
cval = rad*cos(60);
sier3(rad);
translate([sval,-cval,-cval-rad]) sier3(rad);
translate([-sval,-cval,-cval-rad]) sier3(rad);
translate([0,rad,-cval-rad]) sier3(rad);
}
module sier5(rad) {
rad = rad / 2;
sval = rad*sin(60);
cval = rad*cos(60);
sier4(rad);
translate([sval,-cval,-cval-rad]) sier4(rad);
translate([-sval,-cval,-cval-rad]) sier4(rad);
translate([0,rad,-cval-rad]) sier4(rad);
}
rotate([180,0,0]) sier4(30);
zignig Said,
November 7, 2009 @ 1:34 am
Freecad ( http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Main_Page ) is also does parametric.
It uses python.
I’ve not tried it yet but it uses a well known cad core and does fillets and chamfers as well
Revar Said,
November 7, 2009 @ 1:43 pm
Hmm. I played with openSCAD a while longer, and yeah, recursion is impractical as yet. So fractals are a lot harder. I don’t see any vector stack support like push/pop/insert/append, so it’s hard to even fake recursion. Oh well. I’ll have to wait for later releases for that particular fun, I guess.
Bruno Rivard Said,
November 7, 2009 @ 1:44 pm
Elegant and Useful, but not a game changer. NURBS (and now T-splines) have done that too. In free-form graphics and the command line. You can do the same sorts of ultra concise scripts.
Unfortunately there is not any pure and dedicated open source application that utilizes NURBS. Rhino3D (www.rhino3d.com) has an opensource API however.
The new Mac port will use Python for scripting the API. Making an open source “glue” would be a good start.
But till then OpenSCAD does it.
Allan Ecker Said,
November 7, 2009 @ 4:46 pm
Mm.
I have lots of little gripes on this tool, but the core of it is so promising that I have little doubt it’ll attract many users and ultimately enthusiastic coders to fill in the cracks.
failrate Said,
November 7, 2009 @ 11:12 pm
Well, it’s open source. I’m only presuming that the language is not essential to the function of the application. It may be practical to bind a different language to openSCAD or provide an API that could then be SWIG-i-fied for any given language.
For example, I generally work in either Python (standalone apps) or JavaScript (where the scripting language needs to be embedded). In the case of the latter, I’ve embedded the SpiderMonkey runtime into both an openGL-based renderer and a libSDL-based additive sine synthesis engine. It may be relatively easy to replace the ad-hoc language of this with Your-Language-Of-Choice.
OpenSCAD: Constructive solid geometry CAD at long last | china online business,e business,e-commerce consultant Said,
November 26, 2009 @ 6:47 pm
[...] I was really stoked this morning to read this post over on the Thingiverse Blog about the advent of OpenSCAD, which does for 3D CAD what POV-Ray did for raytracing. At long last, [...]
OpenSCAD: A Love Story « Project Blog Said,
November 27, 2009 @ 7:53 am
[...] a belly fully of thanksgiving turkey I tried it out. I agree with the Make post and the referenced Thingaverse post : In the right hands, designing the right parts, this is a game changer. I played around with it [...]