Last active
October 2, 2016 00:06
-
-
Save rbuckland/65a7574f3ec52cd9e89e61037c2a1da3 to your computer and use it in GitHub Desktop.
cube to cylinder merge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module move(x=0,y=0,z=0,rx=0,ry=0,rz=0) { translate([x,y,z])rotate([rx,ry,rz]) children(); } | |
module cube_and_cylinder(dia=10, height=20) { | |
// i often move everything to center .. and "transform/move" it from there | |
// cubes and other shapes are "default" at 0,0,0, but cylinders are at 0,0 for center | |
// so moving the cube to center aligns it with the cube | |
move(rz=45) cube([dia,dia,dia],center=true); | |
// we want a small cylinder to transition from the cube to | |
move(z=dia) cylinder(r=dia/2,h=dia/2); | |
} | |
// put in some default | |
module part(dia=10, height=20) { | |
// merge / mold the two pieces together | |
hull() { | |
cube_and_cylinder(dia, height); | |
} | |
// stick a cylinder on top of our now cubey-cylinder | |
cylinder(r=dia/2,h=height); | |
} | |
part(dia=10, height=40); | |
//cube_and_cylinder(10, 40); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment