platform.scad 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. include <../config/platform.scad>
  2. include <../config/thread.scad>
  3. include <corner.scad>
  4. include <wall.scad>
  5. function platform_full_support_depth()
  6. = platform_support_depth
  7. + thread_height
  8. + platform_thickness;
  9. function platform_top_width()
  10. = platform_width
  11. - corner_radius * 2;
  12. function platform_side_width()
  13. = platform_height
  14. - corner_radius * 2;
  15. function platform_connector_holes() = [
  16. 0,
  17. platform_depth / 2 - corner_radius,
  18. platform_depth / 4 - corner_radius,
  19. -platform_depth / 4 - corner_radius
  20. ];
  21. function platform_connector_space()
  22. = thread_top_diameter
  23. + platform_thickness;
  24. module platform_connector_hole(move_x, move_y, thickness = 0) {
  25. translate([move_x, move_y]) {
  26. if (thickness == 0) {
  27. circle(r = thread_screw / 2);
  28. } else {
  29. cylinder(r = thread_screw / 2, h = thickness, center = true);
  30. }
  31. }
  32. }
  33. module platform_side_holes(thread = false) {
  34. move_x
  35. = platform_side_width() / 2
  36. - corner_radius
  37. - thread_screw;
  38. move_top_y
  39. = platform_full_support_depth() / 2
  40. - thread_screw;
  41. move_bottom_y
  42. = thread_top_diameter / 2
  43. - move_top_y;
  44. module thread(move_x, move_y) {
  45. translate([move_x, move_y]) {
  46. thread_object(false, platform_thickness);
  47. }
  48. }
  49. module screw(move_x, move_y) {
  50. translate([move_x, move_y]) {
  51. thread_screw_object(thread_height);
  52. }
  53. }
  54. if (thread) {
  55. screw(move_x, move_top_y);
  56. screw(0, move_top_y);
  57. thread(move_x, move_bottom_y);
  58. thread(-move_x, move_bottom_y);
  59. } else {
  60. thread_screw_hole(move_x, move_top_y);
  61. thread_screw_hole(0, move_top_y);
  62. thread_screw_hole(move_x, move_bottom_y);
  63. thread_screw_hole(-move_x, move_bottom_y);
  64. }
  65. }
  66. module platform_top_holes(thread = false) {
  67. move_x
  68. = platform_top_width() / 2
  69. - corner_radius
  70. - thread_screw;
  71. move_top_y
  72. = platform_full_support_depth() / 2
  73. - thread_screw;
  74. move_bottom_y
  75. = thread_top_diameter / 2
  76. - move_top_y;
  77. module thread(move_x, move_y) {
  78. translate([move_x, move_y]) {
  79. thread_object(false, platform_thickness);
  80. }
  81. }
  82. module screw(move_x, move_y) {
  83. translate([move_x, move_y]) {
  84. thread_screw_object(thread_height);
  85. }
  86. }
  87. if (thread) {
  88. screw(move_x, move_top_y);
  89. screw(-move_x, move_top_y);
  90. thread(move_x, move_bottom_y);
  91. thread(-move_x, move_bottom_y);
  92. } else {
  93. thread_screw_hole(move_x, move_top_y);
  94. thread_screw_hole(-move_x, move_top_y);
  95. thread_screw_hole(move_x, move_bottom_y);
  96. thread_screw_hole(-move_x, move_bottom_y);
  97. }
  98. }
  99. module platform_mount_object() {
  100. rounding = corner_radius;
  101. holes_width
  102. = platform_width
  103. - rounding * 2
  104. - thread_screw * 2
  105. - platform_side_thickness * 2;
  106. holes_height
  107. = platform_height
  108. - rounding * 2
  109. - thread_screw * 2
  110. - platform_side_thickness;
  111. module base_shape() {
  112. move_x = platform_width / 2 - rounding;
  113. move_y = platform_height / 2 - rounding;
  114. hull() {
  115. corner(move_x, move_y);
  116. corner(-move_x, move_y);
  117. corner(move_x, -move_y);
  118. corner(-move_x, -move_y);
  119. }
  120. }
  121. base_thickness
  122. = platform_thickness
  123. + thread_height;
  124. module base_object() {
  125. linear_extrude(height = base_thickness, center = true) {
  126. base_shape();
  127. }
  128. }
  129. module bottom_object() {
  130. center = base_thickness / 2 - thread_height / 2;
  131. render() {
  132. difference() {
  133. base_object();
  134. translate([0, 0, center]) {
  135. rotate([180, 0, 0]) {
  136. width = holes_width;
  137. height = holes_height;
  138. thickness = platform_thickness;
  139. wall_thread_object(width, height, thickness);
  140. }
  141. }
  142. }
  143. }
  144. }
  145. module side_shape() {
  146. module cutout_shape() {
  147. move_x
  148. = platform_width / 2
  149. - platform_side_thickness
  150. - rounding;
  151. move_top_y
  152. = platform_height / 2
  153. - platform_side_thickness
  154. - rounding;
  155. move_bottom_y
  156. = -platform_height / 2
  157. + rounding;
  158. hull() {
  159. corner(move_x, move_top_y);
  160. corner(-move_x, move_top_y);
  161. corner(move_x, move_bottom_y, false);
  162. corner(-move_x, move_bottom_y, false);
  163. }
  164. }
  165. module bottom_cutout_shape() {
  166. bottom
  167. = rounding / 2
  168. - platform_height / 2;
  169. translate([0, bottom]) {
  170. square([platform_width, rounding], center = true);
  171. }
  172. }
  173. render() {
  174. difference() {
  175. base_shape();
  176. cutout_shape();
  177. bottom_cutout_shape();
  178. }
  179. }
  180. }
  181. module side_object() {
  182. thickness = platform_support_depth;
  183. linear_extrude(height = thickness, center = true) {
  184. side_shape();
  185. }
  186. }
  187. bottom_center
  188. = thread_height / 2
  189. + platform_thickness / 2
  190. - platform_full_support_depth() / 2;
  191. side_center
  192. = platform_support_depth / 2
  193. + thread_height
  194. + platform_thickness
  195. - platform_full_support_depth() / 2;
  196. module layer_base_object() {
  197. translate([0, 0, bottom_center]) {
  198. bottom_object();
  199. }
  200. translate([0, 0, side_center]) {
  201. side_object();
  202. }
  203. }
  204. module top_holes() {
  205. center_y
  206. = platform_height / 2
  207. - thread_height / 2;
  208. translate([0, center_y, 0]) {
  209. rotate([90, 0, 0]) {
  210. platform_top_holes(true);
  211. }
  212. }
  213. }
  214. module left_holes() {
  215. center_x
  216. = platform_width / 2
  217. - thread_height / 2;
  218. translate([center_x, 0, 0]) {
  219. mirror([0, 1, 0]) {
  220. rotate([90, 0, 270]) {
  221. platform_side_holes(true);
  222. }
  223. }
  224. }
  225. }
  226. module right_holes() {
  227. center_x
  228. = thread_height / 2
  229. - platform_width / 2;
  230. translate([center_x, 0, 0]) {
  231. rotate([90, 0, 90]) {
  232. platform_side_holes(true);
  233. }
  234. }
  235. }
  236. render() {
  237. difference() {
  238. layer_base_object();
  239. top_holes();
  240. left_holes();
  241. right_holes();
  242. }
  243. }
  244. }
  245. module platform_top_shape() {
  246. move_x
  247. = platform_top_width() / 2
  248. - corner_radius;
  249. move_y
  250. = platform_depth / 2
  251. - corner_radius;
  252. module base_shape() {
  253. hull() {
  254. corner(move_x, move_y);
  255. corner(-move_x, move_y);
  256. corner(move_x, -move_y);
  257. corner(-move_x, -move_y);
  258. }
  259. }
  260. holes_y
  261. = platform_full_support_depth() / 2
  262. - platform_depth / 2;
  263. module connector_holes() {
  264. for (count = platform_connector_holes()) {
  265. move
  266. = count
  267. - platform_connector_space();
  268. platform_connector_hole(move_x, move);
  269. platform_connector_hole(-move_x, move);
  270. }
  271. }
  272. difference() {
  273. base_shape();
  274. connector_holes();
  275. translate([0, holes_y]) {
  276. platform_top_holes();
  277. }
  278. }
  279. }
  280. module platform_top_object() {
  281. height = platform_thickness;
  282. color("#9711EE") {
  283. render() {
  284. linear_extrude(height = height, center = true) {
  285. platform_top_shape();
  286. }
  287. }
  288. }
  289. }
  290. module platform_side_shape() {
  291. move_x
  292. = platform_side_width() / 2
  293. - corner_radius;
  294. move_y
  295. = platform_depth / 2
  296. - corner_radius;
  297. module base_shape() {
  298. hull() {
  299. corner(0, -move_y / 1.5);
  300. corner(move_x, -move_y / 1.5);
  301. corner(move_x, -move_y);
  302. corner(-move_x, -move_y);
  303. }
  304. hull() {
  305. corner(0, -move_y / 1.5);
  306. corner(move_x, -move_y / 1.5);
  307. corner(move_x, move_y);
  308. }
  309. }
  310. support_holes_y
  311. = platform_full_support_depth() / 2
  312. - platform_depth / 2;
  313. module connector_holes() {
  314. for (count = platform_connector_holes()) {
  315. platform_connector_hole(move_x, count);
  316. }
  317. }
  318. difference() {
  319. base_shape();
  320. connector_holes();
  321. translate([0, support_holes_y]) {
  322. platform_side_holes();
  323. }
  324. }
  325. }
  326. module platform_side_object() {
  327. height = platform_thickness;
  328. color("#DA25B3") {
  329. render() {
  330. linear_extrude(height = height, center = true) {
  331. platform_side_shape();
  332. }
  333. }
  334. }
  335. }
  336. module platform_connector() {
  337. size = platform_connector_space();
  338. cube(size, center = true);
  339. }