3D part design with OpenSCAD #136: Experimenting with spiral designs.

2 min read
By Bob
3D part design with OpenSCAD #136: Experimenting with spiral designs.

After making the code in the last post it occurred to me that I could use two shapes to make the spiral then subtract one from the other to make things like a flat hollow spiral tube or U-shaped trim that could be printed in a spiral to make longer strips. It was pretty easy to adapt the code for two separate coils that could be adjusted independently:

//
/*[Over All]*/
length=3000;//[10:.01:6000]
turn_spacing=40;//[0:.01:100]
divergence=.6;//[.01:.01:2]

/*[Inner Coil]*/
Show_inner_coil=true;
Inner_height=4.7;//[1:.01:50]
Inner_cylinder_r_one=9.8;//[0:.01:100]
Inner_cylinder_r_two=0;//[0:.01:100]
Inner_cylinder_shape=40;//[3:1:100]
Inner_cylinder_spacing=.8;//[.6:.01:20]
Inner_cylinder_rotation=90;//[0:.01:360]

/*[Outer Coil]*/
Show_outer_coil=true;
Outer_height=5;//[1:.01:50]
Outer_cylinder_r_one=22.3;//[0:.01:100]
Outer_cylinder_r_two=0;//[0:.01:100]
Outer_cylinder_shape=3;//[3:1:100]
Outer_cylinder_spacing=20;//[.6:.01:20]
Outer_cylinder_rotation=90;//[0:.01:360]

module inner_coil(){
for(i=[0:Inner_cylinder_spacing:length+1])
   rotate(i*divergence)
   translate([i/turn_spacing,0,0])
   rotate([0,0,Inner_cylinder_rotation])
   cylinder(h=Inner_height,r1=Inner_cylinder_r_one,r2=Inner_cylinder_r_two,$fn=Inner_cylinder_shape);
}

module outer_coil(){
for(j=[0:Outer_cylinder_spacing:length])
 rotate(j*divergence) 
 translate([j/turn_spacing,0,0])
 rotate([0,0,Outer_cylinder_rotation])
 cylinder(h=Outer_height,r1=Outer_cylinder_r_one,r2=Outer_cylinder_r_two,$fn=Outer_cylinder_shape);
}



if(Show_inner_coil)
inner_coil();
if(Show_outer_coil)
outer_coil();

It can make some interesting designs:

Here is a quick example using a sphere and a cube after commenting out the cylinder part of the code:

Trying to difference the two spirals flags a critical error so I saved each coil as an stl file by selecting which one is shown and then did the difference on them.

Cube subtracted from the sphere spiral:

Sphere subtracted from the cube spiral:

With some adjustments you can see it would be pretty easy to make print in place strips any shape to make edge protectors or fill in strips.