Why I <3 OpenSCAD

So my CNC design is coming along nicely now, and I'm really liking developing it in OpenSCAD.  I'm trying to organize everything well to make the design easy to modify and come up with a good work flow for going from designing individual components, to fitting them together into assemblies, to actually generating the toolpaths to cut out the parts on a CNC router.

One of the cool things you can do if you build full assemblies from your individual parts in OpenSCAD (or any CAD program, really) is do a quick first pass of your design and make sure everything fits together nicely.  Here's an example issue I caught when looking at my X-axis assembly:

One of the pipes that span the X-axis frame intersects the spans of the gantry.  To fix this I can open the include file for the X-axis and change a single line that defines how wide the  spans are or the  spacing of the guide rods, recompile, and end up with this:

Problem fixed!  If I extend this approach and make an assembly for each full functional unit, each axis, each tool head, etc., I can throw them all together and see how my whole final machine will look and identify problems with the design before I start cutting parts.  Moreover, others can also easily see how the hole thing fits together, make changes, and check their mods easily as well.  That's the plan at least.

Tags: , ,

5 Responses to “Why I <3 OpenSCAD”

  1. tolomea says:

    How did you find the intersect? By manual observation?

  2. Craig says:

    Yes, I haven’t looked into completely automating it. I have had plans to add coloring to the various components and “vitamins” used in my assemblies to make the various components a little easier to recognize and hopefully make it a bit easier to spot intersections.

  3. tolomea says:

    Some tools support for assemblies would be nice. I’m kind of new at this, but I had this idea overnight that might help you. It’s a drop in replacement for union that you can use whenever you are assembling parts. Normally it should be about as efficient as union. If you set the debug flag it will instead show you any overlaps.

    module assembly(debug=false){
    union(){
    for(i=[0:$children-1])
    {
    if(debug){
    for(j=[0:$children-1]){
    if(i != j){
    echo(“bob”, i, j);
    intersection(){
    child(i);
    child(j);
    }
    }
    }
    }else{
    child(i);
    }
    }
    }
    }

  4. Craig says:

    Oh, I like the idea of taking the intersection of objects in an assembly to detect overlapping components…

  5. tolomea says:

    this one is better

    module assembly(debug=false){
    if(debug){
    union(){
    color([1,0,0,1]){
    for(i=[0:$children-1]){
    for(j=[0:$children-1]){
    if(i != j){
    intersection(){
    child(i);
    child(j);
    }
    }
    }
    }
    }
    color([1,1,0,0.5]){
    for(i=[0:$children-1]){
    child(i);
    }
    }
    }
    }else{
    union(){
    for(i=[0:$children-1]){
    child(i);
    }
    }
    }
    }

    assembly(debug=true){
    cylinder(r=10,h=20,center=true);
    translate([-15,0,0]) cylinder(r=10,h=10,center=true);
    translate([15,0,0]) cylinder(r=10,h=10,center=true);
    }

Leave a Reply