Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.82 KB | None | 0 0
  1. //monoprice maker select spool holder nut 5/20/17 12:05pm
  2.  
  3. thread_od = 31;
  4. thread_step = 1.5; // Z/length distance between each thread, def 1.5
  5. thread_shape_degrees = 30; //smaller thread shape angles make deeper threads
  6. flange_z = 6; //length/thickness of flange to support the part and spool, was 2.5
  7. thread_z = flange_z + 2;
  8.  
  9.  
  10. ttn=round(thread_z/thread_step+2);
  11. st = thread_step;
  12. lt = thread_z;
  13. pf=2*3.14159265*thread_od;
  14. rs = 1.3; //Resolution (lower values for higher resolution, but may slow rendering)
  15. sn=floor(pf/rs);
  16. lfxy=360/sn;
  17. or = thread_od/2;
  18. lf0 = thread_shape_degrees; //step_shape_degrees
  19. ir=or-st/2*cos(lf0)/sin(lf0);
  20. zt=st/sn;
  21.  
  22. module full_thread(ttn,st,sn,zt,lfxy,or,ir) { //thanks aubenc and mike_mattala
  23.     if(ir >= 0.2) {
  24.         for(i=[0:ttn-1]) {
  25.             for(j=[0:sn-1]) {
  26.                 pt = [
  27.                     [0,                  0,                  i*st-st            ],
  28.                     [ir*cos(j*lfxy),     ir*sin(j*lfxy),     i*st+j*zt-st       ],
  29.                     [ir*cos((j+1)*lfxy), ir*sin((j+1)*lfxy), i*st+(j+1)*zt-st   ],
  30.                     [0,                  0,                  i*st               ],
  31.                     [or*cos(j*lfxy),     or*sin(j*lfxy),     i*st+j*zt-st/2     ],
  32.                     [or*cos((j+1)*lfxy), or*sin((j+1)*lfxy), i*st+(j+1)*zt-st/2 ],
  33.                     [ir*cos(j*lfxy),     ir*sin(j*lfxy),     i*st+j*zt          ],
  34.                     [ir*cos((j+1)*lfxy), ir*sin((j+1)*lfxy), i*st+(j+1)*zt      ],
  35.                     [0,                  0,                  i*st+st            ]
  36.                 ];
  37.                 fc = [
  38.                     [1,0,3],[1,3,6],[6,3,8],[1,6,4],
  39.                     [0,1,2],[1,4,2],[2,4,5],[5,4,6],[5,6,7],[7,6,8],
  40.                     [7,8,3],[0,2,3],[3,2,7],[7,2,5]
  41.                 ];
  42.                 polyhedron(points=pt,faces=fc);
  43.             }
  44.         }
  45.     } else {
  46.         echo("Step Degrees too agresive, the thread will not be made!!");
  47.         echo("Try to increase de value for the degrees and/or...");
  48.         echo(" decrease the pitch value and/or...");
  49.         echo(" increase the outer diameter value.");
  50.     }
  51. }
  52.  
  53. module full_thread_clean() {
  54.     difference() {
  55.             full_thread(ttn,st,sn,zt,lfxy,or,ir);
  56.    
  57.             translate([0, 0, -10])
  58.                 cylinder(d=thread_od*2, h=20, center=true, $fn=8);
  59.             translate([0, 0, thread_z+10])
  60.                 cylinder(d=thread_od*2, h=20, center=true, $fn=8);
  61.     }
  62. }
  63.  
  64. module flange() {
  65.     translate([0, 0, flange_z/2])
  66.         difference() {
  67.             cylinder(d=42.7, h=flange_z, center=true, $fn=6);
  68.            
  69.             difference() { //round off the hex edges
  70.                 cylinder(d=42.7, h=flange_z, center=true, $fn=6);
  71.                 cylinder(d=41, h=flange_z, center=true, $fn=18);
  72.             }
  73.  
  74.             difference() { //bevel to clone the original nut for style points
  75.                 cylinder(d=42.7, h=flange_z, center=true, $fn=6);
  76.                 cylinder(d2=42.7+18, d1=42.7-13.5, h=flange_z*2, center=true, $fn=180);
  77.             }
  78.         }
  79. }
  80.  
  81. module positive() {
  82.     flange();
  83. }
  84.  
  85. difference() {
  86.     translate([0, 0, flange_z])
  87.         rotate([180, 0, 0])
  88.             positive();
  89.    
  90.     translate([0, 0, -1])
  91.         full_thread_clean();
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement