Skip to content

Instantly share code, notes, and snippets.

@thehans
Created November 5, 2019 21:49
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/8554e8ab431e9b97dd390a34a1d253e8 to your computer and use it in GitHub Desktop.
Save thehans/8554e8ab431e9b97dd390a34a1d253e8 to your computer and use it in GitHub Desktop.
Backwards compatible rotate_extrude for OpenSCAD with angle parameter
// older versions of OpenSCAD do not support "angle" parameter for rotate_extrude
// this module provides that capability even when using older versions (such as thingiverse customizer)
module rotate_extrude2(angle = 360, convexity = 2, size = 1000) {
module angle_cut(angle = 90, size = 1000) {
x = size*cos((angle / 2));
y = size*sin((angle / 2));
translate([0, 0, -size]) linear_extrude((2 * size)) polygon([[0, 0], [x, y], [x, size], [-size, size], [-size, -size], [x, -size], [x, -y]]);
}
// support for angle parameter in rotate_extrude was added after release 2015.03
// Thingiverse customizer is still on 2015.03
angleSupport = (version_num() > 20150399) ? true : false; // Next openscad releases after 2015.03.xx will have support angle parameter
// Using angle parameter when possible provides huge speed boost, avoids a difference operation
if(angleSupport) rotate_extrude(angle = angle, convexity = convexity) children();
else rotate([0, 0, (angle / 2)]) difference() {
rotate_extrude(convexity = convexity) children();
angle_cut(angle, size);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment