laptop_pocket.scad 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. include <../config/laptop_pocket.scad>
  2. include <../config/thread.scad>
  3. include <../config/wall.scad>
  4. include <../config/cord.scad>
  5. include <../config/hole.scad>
  6. include <thread.scad>
  7. include <hole.scad>
  8. module laptop_pocket_object() {
  9. module back_shape() {
  10. handle_height = laptop_pocket_handle_back_height;
  11. handle_width = laptop_pocket_handle_width;
  12. width = laptop_pocket_width;
  13. height = laptop_pocket_height;
  14. rounding = laptop_pocket_rounding;
  15. module corner(x, y) {
  16. translate([x, y]) {
  17. circle(r = rounding);
  18. }
  19. }
  20. module handle(reverse = false) {
  21. move_left_x = width / 2 - rounding;
  22. move_right_x = move_left_x - handle_width + rounding * 2;
  23. move_y = handle_height / 2 - rounding;
  24. hull() {
  25. corner(reverse ? move_left_x : -move_left_x, move_y);
  26. corner(reverse ? move_right_x : -move_right_x, move_y);
  27. corner(reverse ? move_left_x : -move_left_x, -move_y);
  28. corner(reverse ? move_right_x : -move_right_x, -move_y);
  29. }
  30. }
  31. module center(scale_x = 0, scale_y = 0) {
  32. move_x = width / 2 - rounding - scale_x;
  33. move_bottom_y = rounding - handle_height / 2 + scale_y;
  34. move_top_y = move_bottom_y + height - rounding * 2 - scale_y * 2;
  35. hull() {
  36. corner(move_x, move_top_y);
  37. corner(move_x, move_bottom_y);
  38. corner(-move_x, move_top_y);
  39. corner(-move_x, move_bottom_y);
  40. }
  41. }
  42. module connectors() {
  43. rounding = laptop_pocket_rounding;
  44. module connector(left) {
  45. move_x = left ? (-rounding / 2) : (rounding / 2);
  46. translate([move_x, rounding / 2]) {
  47. difference() {
  48. square(rounding * 2, center = true);
  49. circle(r = rounding);
  50. translate([0, rounding / 2]) {
  51. square([rounding * 2, rounding], center = true);
  52. }
  53. move_x = left ? (-rounding / 2) : (rounding / 2);
  54. translate([move_x, -rounding / 2]) {
  55. square(rounding, center = true);
  56. }
  57. }
  58. }
  59. }
  60. width = laptop_pocket_width - laptop_pocket_handle_width * 2;
  61. height = laptop_pocket_height;
  62. handle_height = laptop_pocket_handle_back_height;
  63. move_x = width / 2 - rounding / 2;
  64. move_y = height - handle_height / 2 + rounding / 2;
  65. translate([move_x, move_y]) {
  66. connector(true);
  67. }
  68. translate([-move_x, move_y]) {
  69. connector(false);
  70. }
  71. }
  72. module base_shape() {
  73. handle(false);
  74. handle(true);
  75. center();
  76. connectors();
  77. }
  78. module hole_shape() {
  79. min_thickness = laptop_pocket_base_thickness * 2
  80. + thread_top_diameter;
  81. default_thickness = laptop_pocket_handle_width;
  82. thickness = max(min_thickness, default_thickness);
  83. center(thickness, thickness);
  84. }
  85. render() {
  86. difference() {
  87. base_shape();
  88. hole_shape();
  89. }
  90. }
  91. }
  92. module front_shape() {
  93. rounding = laptop_pocket_rounding;
  94. width = laptop_pocket_width;
  95. height = laptop_pocket_handle_back_height;
  96. front_height = thread_top_diameter + laptop_pocket_base_thickness * 2;
  97. move_x = width / 2 - rounding;
  98. move_bottom_y = rounding - height / 2;
  99. move_top_y = move_bottom_y + front_height - rounding * 2;
  100. module corner(x, y) {
  101. translate([x, y]) {
  102. circle(r = rounding);
  103. }
  104. }
  105. hull() {
  106. corner(move_x, move_top_y);
  107. corner(move_x, move_bottom_y);
  108. corner(-move_x, move_top_y);
  109. corner(-move_x, move_bottom_y);
  110. }
  111. }
  112. module base_object() {
  113. back_thickness = thread_height + laptop_pocket_base_thickness;
  114. front_thickness = laptop_pocket_laptop_thickness;
  115. thickness = front_thickness + back_thickness;
  116. back_center = back_thickness / 2 - thickness / 2;
  117. front_center = thickness / 2 - front_thickness / 2;
  118. translate([0, back_center, 0]) {
  119. rotate([90, 0, 0]) {
  120. linear_extrude(height = back_thickness, center = true) {
  121. back_shape();
  122. }
  123. }
  124. }
  125. translate([0, front_center, 0]) {
  126. rotate([90, 0, 0]) {
  127. linear_extrude(height = front_thickness, center = true) {
  128. front_shape();
  129. }
  130. }
  131. }
  132. }
  133. module final_object() {
  134. module thread(move_x, move_z, front = false) {
  135. move_y = thread_height / 2
  136. - laptop_pocket_laptop_thickness / 2
  137. - thread_height / 2
  138. - laptop_pocket_base_thickness / 2;
  139. translate([move_x, front ? -move_y : move_y, move_z]) {
  140. rotate([front ? 90 : 270, 0, 0]) {
  141. thread_object();
  142. }
  143. }
  144. }
  145. module back_threads() {
  146. base_width = laptop_pocket_width - thread_top_diameter;
  147. base_height = laptop_pocket_height - thread_top_diameter;
  148. width = base_width - base_width % wall_holes_space;
  149. height = base_height - base_height % wall_holes_space;
  150. move_x = width / 2;
  151. move_y = height / 2;
  152. center_y = laptop_pocket_handle_back_height / 2
  153. - laptop_pocket_height / 2;
  154. for (count_x = [-move_x : wall_holes_space : move_x]) {
  155. for (count_y = [-move_y : wall_holes_space : move_y]) {
  156. thread(count_x, count_y - center_y);
  157. }
  158. }
  159. }
  160. module front_threads() {
  161. move_y = thread_top_diameter / 2
  162. - laptop_pocket_handle_back_height / 2
  163. + laptop_pocket_base_thickness;
  164. base_width = laptop_pocket_width -
  165. thread_top_diameter;
  166. width = base_width
  167. - base_width % wall_holes_space;
  168. move_x = width / 2;
  169. for (count_x = [-move_x : wall_holes_space : move_x]) {
  170. thread(count_x, move_y, true);
  171. }
  172. }
  173. module single_cord(move_x) {
  174. radius = cord_hole_diameter / 2;
  175. height = thread_height + laptop_pocket_base_thickness;
  176. move_y = height / 2
  177. - laptop_pocket_laptop_thickness / 2
  178. - height / 2;
  179. move_z = laptop_pocket_handle_back_height / 2
  180. - radius / 2
  181. - laptop_pocket_base_thickness * 2;
  182. translate([move_x, move_y, move_z]) {
  183. rotate([90, 0, 0]) {
  184. cylinder(r = radius, h = height, center = true);
  185. }
  186. }
  187. }
  188. module cords() {
  189. move_x = laptop_pocket_width / 2
  190. - laptop_pocket_handle_width / 2;
  191. single_cord(move_x);
  192. single_cord(-move_x);
  193. }
  194. color("#37c887") {
  195. render() {
  196. difference() {
  197. base_object();
  198. back_threads();
  199. front_threads();
  200. cords();
  201. }
  202. }
  203. }
  204. }
  205. final_object();
  206. }
  207. module laptop_pocket_front_shape() {
  208. module base_shape() {
  209. width = laptop_pocket_width;
  210. height = laptop_pocket_handle_front_height;
  211. rounding = laptop_pocket_rounding;
  212. move_x = width / 2 - rounding;
  213. move_y = height / 2 - rounding;
  214. module corner(move_x, move_y) {
  215. translate([move_x, move_y]) {
  216. circle(r = rounding);
  217. }
  218. }
  219. hull() {
  220. corner(move_x, move_y);
  221. corner(move_x, -move_y);
  222. corner(-move_x, move_y);
  223. corner(-move_x, -move_y);
  224. }
  225. }
  226. module center_holes() {
  227. move_y = 0;
  228. base_width = laptop_pocket_width;
  229. width = base_width - base_width % wall_holes_space;
  230. move_x = width / 2;
  231. module hole(move_x) {
  232. translate([move_x, move_y]) {
  233. circle(r = thread_screw / 2);
  234. }
  235. }
  236. for (count = [-move_x : wall_holes_space : move_x]) {
  237. hole(count);
  238. }
  239. }
  240. module feature_holes(move_y, split) {
  241. module hole(move_x) {
  242. translate([move_x, move_y]) {
  243. rotate(split ? 180 : 0) {
  244. hole_shape();
  245. }
  246. }
  247. }
  248. base_width = laptop_pocket_width;
  249. width = base_width - base_width % wall_holes_space;
  250. move_x = width / 2;
  251. for (count = [-move_x : wall_holes_space : move_x]) {
  252. hole(count);
  253. }
  254. }
  255. feature_holes_y = laptop_pocket_handle_front_height / 2
  256. - hole_full_height() / 2
  257. - laptop_pocket_rounding;
  258. module top_holes() {
  259. feature_holes(feature_holes_y, false);
  260. }
  261. module bottom_holes() {
  262. feature_holes(-feature_holes_y, true);
  263. }
  264. difference() {
  265. base_shape();
  266. center_holes();
  267. top_holes();
  268. bottom_holes();
  269. }
  270. }
  271. module laptop_pocket_front_object() {
  272. color("#3b71c4") {
  273. render() {
  274. thickness = laptop_pocket_front_thickness;
  275. linear_extrude(height = thickness, center = true) {
  276. laptop_pocket_front_shape();
  277. }
  278. }
  279. }
  280. }