[OpenSCAD] mixing 2D and 3D

jon jon at jonbondy.com
Sat Jun 25 17:58:16 EDT 2016


I'm playing around with moldings.  I thought I was careful to keep all 
of the 2D stuff together and all of the 3D stuff together, but I guess I 
was wrong.

1) if I do a hull() on 2D objects, don't I get a 2D object as a result?

2) can a module() return a 2D object?

3) sure would be nice if the error messages gave even a HINT about where 
the problem was.  I doubt that I am the first to whine about this.

Thanks

Jon

---

$fn = 100;
eps = 0.1;

module RoundedSquare(x, y) {
     hull() {
         translate([0,     1]) square(1);
         translate([x-4, y-4]) circle(4);
         translate([x-1,   1]) square(1);
         translate([0,   y-1]) square(1);
         }
     }

module CrossSection1()
     difference() {
         union() {
             square([10, 20]);
             translate([10, 3])
                 circle(2);
             }
         translate([10, 15])
             circle(2);
         }

CrossSection1();

translate([0, 30, 0])
     CrossSection2();

module CrossSection2()
     difference() {
         union() {
             RoundedSquare(10, 20);
             translate([10, 12])
                 circle(2);
             }
         translate([10, 5])
             circle(2);
         }

translate([80, 0, 0])
     rotate([0, -90, 0])
         linear_extrude(height = 50)
             CrossSection1();

translate([80, 30, 0])
     rotate([0, -90, 0])
         linear_extrude(height = 50)
             CrossSection2();

difference() {
     translate([-50, 50 + 15, 0])
         rotate([0, -90, 90])
             linear_extrude(height = 50)
                 CrossSection2();
     translate([-50, 0, -eps])
         rotate([0, -90, 0])
             linear_extrude(height = 50)
                 CrossSection2();
     }





More information about the Discuss mailing list