Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.