Skip to content

Instantly share code, notes, and snippets.

@winder
Last active January 1, 2016 02:19
Show Gist options
  • Save winder/8078442 to your computer and use it in GitHub Desktop.
Save winder/8078442 to your computer and use it in GitHub Desktop.
module square_funnel(steps, thickness, height,
s_dim, s_oRadius, s_iRadius,
e_dim, e_oRadius, e_iRadius)
{
// Calculate interpolation steps.
extrude_length = height / steps;
w_s = (e_dim[0] - s_dim[0]) / steps;
l_s = (e_dim[1] - s_dim[1]) / steps;
ir_s = (e_iRadius - s_iRadius) / steps;
or_s = (e_oRadius - s_oRadius) / steps;
// Starting stuff
w = s_dim[0];
l = s_dim[1];
ir = s_iRadius;
or = s_oRadius;
// Join together a whole bunch of extrusions
union()
{
for (i=[0:steps])
{
// Move up to the next step
translate([0,0,i*extrude_length])
// Extrude one section
linear_extrude(
height = extrude_length,
center = true)
// Create a hollow rounded rect
// Add the interpolation to each variable
difference() {
rounded_square(
[w + (w_s*i), l + (l_s*i)],
[or + (or_s*i),or + (or_s*i),or + (or_s*i),or + (or_s*i)],
true);
rounded_square(
[w + (w_s*i) - (thickness*2), l + (l_s*i) - (thickness*2)],
[ir + (ir_s*i),ir + (ir_s*i),ir + (ir_s*i),ir + (ir_s*i)],
true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment