[OpenSCAD] OpenSCAD Digest, Vol 16, Issue 5

Evan T. Jones evan_t_jones at mac.com
Wed Mar 9 18:39:08 CET 2011


On Mar 9, 2011, at 9:23 AM, openscad-request at rocklinux.org wrote:

> Yes I agree. I do like the openscad syntax for creating models though.

Me too!  But they're not so different.  See below.

OK, ok, I'll stop spamming y'all about the Python....



OpenSCAD:

EPSILON = 0.01;
doohickey_h = 10;
m3_rad = 1.4;

module hole_cyl(){
	translate([0,0,-EPSILON]){
		cylinder(r=m3_rad, h=doohickey_h+2*EPSILON );
	}
}

module doohickey(){
	difference(){
		cube([30, 10, doohickey_h], center=true);
		translate([-10, 0,0]){ hole_cyl();}
		hole_cyl();
		translate([10,0,0]){ hole_cyl();}
	}
}
doohickey();

Python: 

EPSILON = 0.01;
doohickey_h = 10;
m3_rad = 1.4;

def doohickey():
    hole_cyl = translate([0,0,-EPSILON])(
                    cylinder(r=m3_rad, h=doohickey_h+2*EPSILON )
                )
    return difference()(
            	cube([30, 10, doohickey_h], center=True),
            	translate([-10, 0,0])( hole_cyl),
            	hole_cyl,
            	translate([10,0,0])( hole_cyl)
            )

doohickey()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rocklinux.net/pipermail/openscad/attachments/20110309/5849b48a/attachment.html


More information about the OpenSCAD mailing list