Advertisement
KeithFromCanada

OpenSCAD header

Jan 4th, 2021
1,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //--------------------------------
  2. // {Project Name}
  3. // {Creator Name}
  4. // CC {Year}
  5. // OpenSCAD
  6. //--------------------------------
  7.  
  8. // Thingiverse Customizer Docs: http://customizer.makerbot.com/docs
  9.  
  10. // OpenSCAD uses millimeters (mm) for units.
  11. // Distance functions are both for conversion and to state plainly that a number is a
  12. //    distance measurement, not just a value.
  13. // Fractions are interpreted as formulas: '1 3/4' = '1+3/4' = 1.75
  14. function mm(x = 1)     = x *    1.00000;
  15. function cm(x = 1)     = x *   10.00000;
  16. function m(x = 1)      = x * 1000.00000;
  17. function inches(x = 1) = x *   25.40000;  
  18. function feet(x = 1)   = x *   25.40000 * 12;  
  19. function yards(x = 1)  = x *   25.40000 * 12 * 3;  
  20.  
  21. function twice(x = 1)  = x *    2.00000;
  22. function half(x = 1)   = x *    0.50000;
  23.  
  24. // Segments used for circles/cylinders have their *endpoints* on the radius.  This means that
  25. //    cylinders used for holes will be too small; the *midpoints* need to be on the radius,
  26. //    not the *endpoints*.  This function returns properly sized radii for holes.
  27. function midpoint_radius (endpoint_radius, num_facets) = endpoint_radius / cos(360/(num_facets*2));
  28.  
  29. // OpenSCAD uses degrees (deg) for units.
  30. // Angle functions are both for conversion and to state plainly that a number is a
  31. //    angle measurement, not just a value.
  32. _pi   = 3.14159265359 * 1.0;  // (Made into an equation so that Customizer won't pick it up.)
  33.  
  34. function deg(x = 1) = x;
  35. function rad(x = 1) = x * (180 / _pi);
  36.  
  37. // Creates a vector that points from the origin to a specific point in space.
  38. function rotateto(x=1,y=1,z=1) = [0,acos(z/norm([x,y,z])),atan2(y,x)];
  39.  
  40. // Sets different curve smoothnesses for draft <F5> and render <F6> views
  41. draft_quality = 12; // [12:6:360]
  42. final_quality = 72; // [12:6:360]
  43. smoothness =$preview ? draft_quality : final_quality; // (Circles are divided in $fn line segments.)
  44. // echo($preview,smoothness);
  45. $fn = smoothness;
  46.  
  47. //--------------------------------------------------------------------------------------------
  48. /*/
  49. //*/
  50. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement