example017.scad 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // To render the DXF file from the command line:
  2. // openscad -x example017.dxf -D'mode="parts"' example017.scad
  3. // mode = "parts";
  4. // mode = "exploded";
  5. mode = "assembled";
  6. thickness = 6;
  7. locklen1 = 15;
  8. locklen2 = 10;
  9. boltlen = 15;
  10. midhole = 10;
  11. inner1_to_inner2 = 50;
  12. total_height = 80;
  13. module shape_tripod()
  14. {
  15. x1 = 0;
  16. x2 = x1 + thickness;
  17. x3 = x2 + locklen1;
  18. x4 = x3 + thickness;
  19. x5 = x4 + inner1_to_inner2;
  20. x6 = x5 - thickness;
  21. x7 = x6 - locklen2;
  22. x8 = x7 - thickness;
  23. x9 = x8 - thickness;
  24. x10 = x9 - thickness;
  25. y1 = 0;
  26. y2 = y1 + thickness;
  27. y3 = y2 + thickness;
  28. y4 = y3 + thickness;
  29. y5 = y3 + total_height - 3*thickness;
  30. y6 = y5 + thickness;
  31. union()
  32. {
  33. difference() {
  34. polygon([
  35. [ x1, y2 ], [ x2, y2 ],
  36. [ x2, y1 ], [ x3, y1 ], [ x3, y2 ],
  37. [ x4, y2 ], [ x4, y1 ], [ x5, y1 ],
  38. [ x5 + thickness, y3 ], [ x5, y4 ],
  39. [ x5, y5 ],
  40. [ x6, y5 ], [ x6, y6 ], [ x7, y6 ], [ x7, y5 ], [ x8, y5 ],
  41. [ x8, y6 ], [ x9, y5 ],
  42. [ x9, y4 ], [ x10, y3 ],
  43. [ x2, y3 ]
  44. ]);
  45. translate([ x10, y4 ]) circle(thickness);
  46. translate([ x5 + thickness, y4 ]) circle(thickness);
  47. }
  48. translate([ x5, y1 ])
  49. square([ boltlen - thickness, thickness*2 ]);
  50. translate([ x5 + boltlen - thickness, y2 ]) circle(thickness);
  51. translate([ x2, y2 ]) intersection() {
  52. circle(thickness);
  53. translate([ -thickness*2, 0 ]) square(thickness*2);
  54. }
  55. translate([ x8, y5 ]) intersection() {
  56. circle(thickness);
  57. translate([ -thickness*2, 0 ]) square(thickness*2);
  58. }
  59. }
  60. }
  61. module shape_inner_disc()
  62. {
  63. difference() {
  64. circle(midhole + boltlen + 2*thickness + locklen2);
  65. for (alpha = [ 0, 120, 240 ])
  66. rotate(alpha) translate([ 0, midhole + boltlen + thickness + locklen2/2 ]) square([ thickness, locklen2 ], true);
  67. circle(midhole + boltlen);
  68. }
  69. }
  70. module shape_outer_disc()
  71. {
  72. difference() {
  73. circle(midhole + boltlen + inner1_to_inner2 + 2*thickness + locklen1);
  74. for (alpha = [ 0, 120, 240 ])
  75. rotate(alpha) translate([ 0, midhole + boltlen + inner1_to_inner2 + thickness + locklen1/2 ]) square([ thickness, locklen1 ], true);
  76. circle(midhole + boltlen + inner1_to_inner2);
  77. }
  78. }
  79. module parts()
  80. {
  81. tripod_x_off = locklen1 - locklen2 + inner1_to_inner2;
  82. tripod_y_off = max(midhole + boltlen + inner1_to_inner2 + 4*thickness + locklen1, total_height);
  83. shape_inner_disc();
  84. shape_outer_disc();
  85. for (s = [ [1,1], [-1,1], [1,-1] ])
  86. scale(s) translate([ tripod_x_off, -tripod_y_off ]) shape_tripod();
  87. }
  88. module exploded()
  89. {
  90. translate([ 0, 0, total_height + 2*thickness ]) linear_extrude(height = thickness, convexity = 4) shape_inner_disc();
  91. linear_extrude(height = thickness, convexity = 4) shape_outer_disc();
  92. color([ 0.7, 0.7, 1 ]) for (alpha = [ 0, 120, 240 ])
  93. rotate(alpha) translate([ 0, thickness*2 + locklen1 + inner1_to_inner2 + boltlen + midhole, 1.5*thickness ])
  94. rotate([ 90, 0, -90 ]) linear_extrude(height = thickness, convexity = 10, center = true) shape_tripod();
  95. }
  96. module bottle()
  97. {
  98. r = boltlen + midhole;
  99. h = total_height - thickness*2;
  100. rotate_extrude(convexity = 2)
  101. {
  102. square([ r, h ]);
  103. translate([ 0, h ])
  104. intersection() {
  105. square([ r, r ]);
  106. scale([ 1, 0.7 ]) circle(r);
  107. }
  108. translate([ 0, h+r ])
  109. intersection() {
  110. translate([ 0, -r/2 ]) square([ r/2, r ]);
  111. circle(r/2);
  112. }
  113. }
  114. }
  115. module assembled()
  116. {
  117. translate([ 0, 0, total_height - thickness ]) linear_extrude(height = thickness, convexity = 4) shape_inner_disc();
  118. linear_extrude(height = thickness, convexity = 4) shape_outer_disc();
  119. color([ 0.7, 0.7, 1 ]) for (alpha = [ 0, 120, 240 ])
  120. rotate(alpha) translate([ 0, thickness*2 + locklen1 + inner1_to_inner2 + boltlen + midhole, 0 ])
  121. rotate([ 90, 0, -90 ]) linear_extrude(height = thickness, convexity = 10, center = true) shape_tripod();
  122. % translate([ 0, 0, thickness*2]) bottle();
  123. }
  124. if (mode == "parts")
  125. parts();
  126. if (mode == "exploded")
  127. exploded();
  128. if (mode == "assembled")
  129. assembled();