3d part design with OpenScad #71: Using hull and spheres to make a slinky and improve the thread module.

2 min read
By Bob
3d part design with OpenScad #71: Using hull and spheres to make a slinky and improve the thread module.

I was experimenting with using a sphere for the thread module to see what the results looked like and it works really well, the rendering is fast on the new development builds and the steps in the for loop can be adjusted to make a super smooth spiral.

Update: I forgot to add rotate in a couple of places so the results were out of round with some settings, the modified code below fixed that.

Here is the modified code:

/*[Threads]*/
Show_Threads = true;
Thread_pitch = 16;//[0:.001:16]
Thread_diameter = 32.5;//[0:.001:100]
Thread_diameter2 =50;//[.1:.001:100]
Thread_height = 50;//[0:.001:100]
Thread_shape = 4;//[3:1:10]
Thread_thickness = .5;//[.1:.001:12]
Thread_thickness2 = .5;//[.1:.001:12]
Move_Threads_X = 0; // [0:.01:400]
Move_Threads_Y = 0; // [0:.01:400]
Move_Threads_Z = 0; // [-400:.01:400]
Rotate_Threads_X = 0; // [0:.01:360]
Rotate_Threads_Y = 0; // [0:.01:360]
Rotate_Threads_Z = 0; // [0:.01:360]

Tn=100*Thread_pitch;
Pitch_angle=360*Thread_pitch;

module Threads(){
  if(Show_Threads)  
  rotate([Rotate_Threads_X,Rotate_Threads_Y,Rotate_Threads_Z])
  translate([Move_Threads_X,Move_Threads_Y,Move_Threads_Z])
for (i =[0.1:.5:Tn]){
 hull(){
 translate([Thread_diameter/2*cos(i*Pitch_angle/Tn),Thread_diameter/2*sin(i*Pitch_angle/Tn),Thread_height*(i/Tn)])
    rotate(a=180+(i*(Pitch_angle/Tn)),v=[0,0,.1])
    rotate(a=90,v=[.1,0,0])
    sphere(Thread_thickness,$fn=Thread_shape);
 translate([Thread_diameter/2*cos((i+1)*Pitch_angle/Tn),Thread_diameter/2*sin((i+1)*Pitch_angle/Tn),Thread_height*(i+1)/Tn])
    rotate(a=180+(i*(Pitch_angle/Tn)),v=[0,0,.1])
    rotate(a=90,v=[.1,0,0])
    sphere(Thread_thickness,$fn=Thread_shape);
 translate([Thread_diameter2/2*cos(i*Pitch_angle/Tn),Thread_diameter2/2*sin(i*Pitch_angle/Tn),Thread_height*(i/Tn)])
    sphere(Thread_thickness2,$fn=Thread_shape);
 translate([Thread_diameter2/2*cos((i+1)*Pitch_angle/Tn),Thread_diameter2/2*sin((i+1)*Pitch_angle/Tn),Thread_height*(i+1)/Tn])
    sphere(Thread_thickness2,$fn=Thread_shape);   
}
}}
//
Threads();


It takes a few seconds longer to render if the steps are reduced to .1, but the results look pretty good.

Here you can see the effect of using a sphere to create the spiral:

By adjusting the sphere thickness the thread profile can be modified:

I always print springs on their side:

By using a sphere instead of a cylinder the threads appear to be much smoother and render a lot faster, I will be making improvements as soon as I can print out some test models.