platform.scad 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. color("#4C4CB3") {
  237. render() {
  238. difference() {
  239. layer_base_object();
  240. top_holes();
  241. left_holes();
  242. right_holes();
  243. }
  244. }
  245. }
  246. }
  247. module platform_top_shape() {
  248. move_x
  249. = platform_top_width() / 2
  250. - corner_radius;
  251. move_y
  252. = platform_depth / 2
  253. - corner_radius;
  254. module base_shape() {
  255. hull() {
  256. corner(move_x, move_y);
  257. corner(-move_x, move_y);
  258. corner(move_x, -move_y);
  259. corner(-move_x, -move_y);
  260. }
  261. }
  262. holes_y
  263. = platform_full_support_depth() / 2
  264. - platform_depth / 2;
  265. module connector_holes() {
  266. for (count = platform_connector_holes()) {
  267. move
  268. = count
  269. - platform_connector_space();
  270. platform_connector_hole(move_x, move);
  271. platform_connector_hole(-move_x, move);
  272. }
  273. }
  274. module mounting_holes() {
  275. radius = platform_mounting_holes_diameter / 2;
  276. for (count = platform_mounting_holes_positions) {
  277. translate([count.y, count.x]) {
  278. circle(r = radius);
  279. }
  280. }
  281. }
  282. difference() {
  283. base_shape();
  284. connector_holes();
  285. mounting_holes();
  286. translate([0, holes_y]) {
  287. platform_top_holes();
  288. }
  289. }
  290. }
  291. module platform_top_object() {
  292. height = platform_thickness;
  293. color("#9711EE") {
  294. render() {
  295. linear_extrude(height = height, center = true) {
  296. platform_top_shape();
  297. }
  298. }
  299. }
  300. }
  301. module platform_side_shape() {
  302. move_x
  303. = platform_side_width() / 2
  304. - corner_radius;
  305. move_y
  306. = platform_depth / 2
  307. - corner_radius;
  308. module base_shape() {
  309. hull() {
  310. corner(0, -move_y / 1.5);
  311. corner(move_x, -move_y / 1.5);
  312. corner(move_x, -move_y);
  313. corner(-move_x, -move_y);
  314. }
  315. hull() {
  316. corner(0, -move_y / 1.5);
  317. corner(move_x, -move_y / 1.5);
  318. corner(move_x, move_y);
  319. }
  320. }
  321. support_holes_y
  322. = platform_full_support_depth() / 2
  323. - platform_depth / 2;
  324. module connector_holes() {
  325. for (count = platform_connector_holes()) {
  326. platform_connector_hole(move_x, count);
  327. }
  328. }
  329. difference() {
  330. base_shape();
  331. connector_holes();
  332. translate([0, support_holes_y]) {
  333. platform_side_holes();
  334. }
  335. }
  336. }
  337. module platform_side_object() {
  338. height = platform_thickness;
  339. color("#DA25B3") {
  340. render() {
  341. linear_extrude(height = height, center = true) {
  342. platform_side_shape();
  343. }
  344. }
  345. }
  346. }
  347. function platform_connector_depth()
  348. = platform_thickness * 2
  349. + thread_screw / 2
  350. + corner_radius * 2;
  351. function platform_connector_width()
  352. = platform_connector_space()
  353. + platform_thickness * 2
  354. + thread_screw;
  355. module platform_connector_object(split = false) {
  356. thickness = platform_thickness;
  357. corner = corner_radius;
  358. width = platform_connector_depth();
  359. module corner() {
  360. outside = corner * 2;
  361. inside = outside - thickness * 2;
  362. module center() {
  363. difference() {
  364. circle(r = outside / 2);
  365. circle(r = inside / 2);
  366. }
  367. }
  368. module differ() {
  369. translate([0, -outside / 4]) {
  370. square([outside, outside / 2], center = true);
  371. }
  372. translate([-outside / 4, outside / 4]) {
  373. square([outside / 2, outside / 2], center = true);
  374. }
  375. }
  376. translate([-outside / 4, -outside / 4]) {
  377. render() {
  378. difference() {
  379. center();
  380. differ();
  381. }
  382. }
  383. }
  384. }
  385. module side(rotation = 0) {
  386. move = width / 2 - corner / 2 - thickness / 2;
  387. rotate(rotation) {
  388. hull() {
  389. translate([move, 0]) {
  390. square(thickness, center = true);
  391. }
  392. translate([-move, 0]) {
  393. circle(r = thickness / 2);
  394. }
  395. }
  396. }
  397. }
  398. module base_shape() {
  399. corner_move = width / 2 - corner / 2;
  400. top_side_x = -corner / 2;
  401. top_side_y = width / 2 - thickness / 2;
  402. side_x = top_side_y;
  403. side_y = top_side_x;
  404. translate([corner_move, corner_move]) {
  405. corner();
  406. }
  407. translate([top_side_x, top_side_y]) {
  408. side();
  409. }
  410. translate([side_x, side_y]) {
  411. side(90);
  412. }
  413. }
  414. depth = platform_connector_width();
  415. module top_screw() {
  416. move_x
  417. = width / 2
  418. - corner_radius * 2;
  419. move_y
  420. = width / 2
  421. - thickness / 2;
  422. move_z
  423. = -platform_connector_space() / 2;
  424. translate([move_x, move_y, move_z]) {
  425. rotate([90, 0, 0]) {
  426. thread_screw_object(thickness);
  427. }
  428. }
  429. }
  430. module side_screw() {
  431. move_x
  432. = width / 2
  433. - thickness / 2;
  434. move_y
  435. = width / 2
  436. - corner_radius * 2;
  437. move_z
  438. = platform_connector_space() / 2;
  439. translate([move_x, move_y, move_z]) {
  440. rotate([0, 90, 0]) {
  441. thread_screw_object(thickness);
  442. }
  443. }
  444. }
  445. module base_object() {
  446. linear_extrude(height = depth, center = true) {
  447. base_shape();
  448. }
  449. }
  450. module object() {
  451. render() {
  452. difference() {
  453. base_object();
  454. top_screw();
  455. side_screw();
  456. }
  457. }
  458. }
  459. color("#3CC361") {
  460. if (split) {
  461. object();
  462. } else {
  463. mirror([1, 0, 0]) {
  464. object();
  465. }
  466. }
  467. }
  468. }