Skip to content

Instantly share code, notes, and snippets.

@atnbueno
Last active January 26, 2016 20:59
Show Gist options
  • Save atnbueno/f6d736b0709d424ad748 to your computer and use it in GitHub Desktop.
Save atnbueno/f6d736b0709d424ad748 to your computer and use it in GitHub Desktop.
An OpenSCAD script to get a partial rotate_extrude
rotate_extrude_angle(90) translate([10, 0, 0]) circle(5);
// A workaround until the new "angle" parameter of rotate_extrude arrives to the public release
module rotate_extrude_angle(angle, r=9999) {
intersection() {
rotate_extrude() children(0);
translate([0, 0, -r/2]) linear_extrude(r) circle_sector(r, 0, angle); // see below
}
}
module circle_sector(r, from, to) {
intersection() {
circle(r);
if (abs(to - from) < 360) { // Less than 360?? then substract to get sector
to = to + ((to <= from) ? 360 : 0); // ensure (from < to)
angles = concat([for(angle = [from:$fa:to-0.1]) angle], to);
polygon(concat([[0, 0]], [for (angle = angles) [(0.1+r)*cos(angle),(0.1+r)*sin(angle)]]));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment