OpenSCAD

Lines, hull()

Now that hull() works with 3D objects you can use this function to create lines.


How do I do this?

  1. If you do not have OpenSCAD installed, download the application from openscad.org


  2. So how does hull() help you in OpenSCAD?

    Here is a simple line.
    hull(){
        translate([0,0,0])
        cube([.5,.5,.5]);
        translate([20,10,0])
       cube([.5,.5,.5]);
    }
    


    or
    linear_extrude(height=1)
    hull(){
        translate([0,0,0])
        circle(.5);
        translate([20,10,0])
        circle(.5);
    }
    



  3. You can and should create a module for drawing lines:
    module line(start=[0,0,0],end,thickness=.5){
        hull(){
            translate(start)
            cube([thickness,thickness,thickness]);
            translate(end)
            cube([thickness,thickness,thickness]);
        }
    }
    or
    $fn=128;
    
    module line(start=[0,0,0],end,thickness=.5){
        linear_extrude(height=thickness)
        hull(){
            translate(start)
            circle(thickness/2);
            translate(end)
            circle(thickness/2);
        }
    }



  4. Save this file as lineMaker.scad


  5. Create a new OpenSCAD document and save it in the same location as lineMaker.scad


  6. The first line of your new document should be:
    use<lineMaker.scad>
    



  7. Then to create a line that starts at 0,0,0 with a thickness of .5 you would type:
    line([20,10,0]);
      
    To create the same line, but with a thickness of 2, type
    line([0,0,0],[20,10,0],2);
      



  8. Using your line() make a square where your lines are 1mm thick:



  • Create a new form that uses the line() module.




  • Why am I doing this?

    OpenSCAD allows you to generate interesting forms by working parametrically and with external files. This tutorial also demonstrated how to take advantage of the hull() function.

    Now what?

    1. Upload your form that takes advantage of lineMaker.scad and line() to Thingiverse
    2. Come back tomorrow for more information and inspiration!