Skip to content

Instantly share code, notes, and snippets.

@thehans
Created November 23, 2019 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehans/56f4cc63f5f7ad941c516b93eba67c8d to your computer and use it in GitHub Desktop.
Save thehans/56f4cc63f5f7ad941c516b93eba67c8d to your computer and use it in GitHub Desktop.
Example of creating a cutout for a 3D object which is pivoting around the origin.
module rotate_extrude3D(clearance, bounds=[1000,1000]) {
rotate_extrude()
intersection() { // clip to positive x axis before rotate_extrude
translate([0,-bounds[1]/2]) square(bounds);
offset(delta=clearance) // add clearance to profile
union() for(a=[-90:$fa:90]) // union projections from multiple angles
projection() rotate([-90,a]) children();
}
}
difference() {
translate([0,0,-10]) cube([100,100,100]);
// assumes object is pointing along positive X axis before sweeping
rotate_extrude3D(clearance=0.5, $fs=1, $fa=1) mything();
}
// View -> animate to show sweeping
%rotate($t*360) mything();
module mything() {
union() {
cube([50,20,2]);
cube([50,2,10]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment