Advertisement
Guest User

Untitled

a guest
Jan 7th, 2025
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1.  
  2. // ===== PARAMETERS ===== //
  3.  
  4. /* [General Settings] */
  5.  
  6. angle = 7.5; // [25:1:45]
  7.  
  8.  
  9. // Angle the back to fix siding
  10. siding_angle = -5; // siding angle (e.g. -12)
  11. siding_extra_offset = 7.5; // extra offset to provide enough depth to account for the extra cut
  12.  
  13. mount_door_side = 1; // [0:left, 1:right]
  14.  
  15. trim_back_edge = false;
  16.  
  17. rotate_for_printing = true;
  18.  
  19. /* [Setup Parameters] */
  20. $fa = 3;
  21. $fs = 0.25;
  22.  
  23.  
  24.  
  25. // ===== IMPLEMENTATION ===== //
  26.  
  27. module screw_hole (offset = [0, 0, 0]) {
  28. translate(offset) {
  29.  
  30. color("cyan")
  31. mirror([0, 0, 1])
  32. cylinder(depth, screw_hole_radius, screw_hole_radius);
  33.  
  34. color("blue")
  35. translate([0, 0, -screw_hole_indent_depth])
  36. linear_extrude(height = screw_hole_indent_depth + epsilon * 2) {
  37. offset(r = screw_hole_indent_corner_radius) {
  38. square(screw_hole_indent_size - [screw_hole_indent_corner_radius, screw_hole_indent_corner_radius] * 2.0, center = true);
  39. }
  40. }
  41. }
  42. }
  43.  
  44. module access_holes () {
  45.  
  46. translate([0, 0, -(outer_size.y / 2.0 + epsilon)]) {
  47. translate([pin_hole_offset.x, -pin_hole_offset.y, -pin_hole_depth/2]) {
  48.  
  49. cylinder(pin_hole_depth, pin_hole_outer_radius, pin_hole_outer_radius);
  50.  
  51. translate( [-pin_hole_outer_radius,0,0] )
  52. cube([pin_hole_outer_radius*2,10,pin_hole_depth]);
  53.  
  54. }
  55.  
  56. // slit
  57. translate([0, -slit_top_offset, 0])
  58. linear_extrude(height = pin_hole_depth + epsilon)
  59. offset(r = slit_corner_radius)
  60. square(slit_size - [slit_corner_radius, slit_corner_radius] * 2.0, center = true);
  61. }
  62. }
  63.  
  64.  
  65. min_edge_height = 6.5;
  66.  
  67. outer_size = [53.0, 162.5];
  68. depth = 100;
  69. inner_depth = 8.5;
  70.  
  71. corner_radius = 11;
  72. chamfer = [5, 5];
  73. wall_thickness = [1.0, 1.0];
  74. lip_height = 0.65;
  75.  
  76. inner_size = outer_size - wall_thickness * 2.0;
  77.  
  78. inner_bottom_size = inner_size - chamfer * 2.0;
  79. inner_bottom_scale = [inner_bottom_size.x / inner_size.x, inner_bottom_size.y / inner_size.y];
  80.  
  81. inner_hole_size = [ 31.0, 50.5 ];
  82. inner_hole_scale = inner_hole_size.x / outer_size.x;
  83. inner_hole_corner_radius = corner_radius * inner_hole_scale;
  84.  
  85. screw_hole_indent_size = [19.0, 14.0];
  86. screw_hole_indent_depth = 1.25;
  87. screw_hole_indent_corner_radius = 1;
  88. screw_hole_diameter = 6.2;
  89. screw_hole_radius = screw_hole_diameter / 2.0;
  90. screw_hole_distance = 67.5;
  91. screw_hole_offset = screw_hole_distance / 2.0;
  92. screw_hole_depth = depth;
  93.  
  94. // slit
  95. slit_size = [5.0, 1.1];
  96. slit_corner_radius = 0.5;
  97. slit_top_offset = 2.25 + slit_size.y / 2.0;
  98.  
  99. // hole
  100. // G4 pro 4.75mm
  101. pin_hole_offset = [9.5, 3.5];
  102. pin_hole_width = 4.75;
  103. pin_hole_outer_diameter = pin_hole_width;
  104. pin_hole_depth = 10;
  105. pin_hole_outer_radius = pin_hole_outer_diameter / 2.0;
  106.  
  107. // wedge cut
  108. wedge_cut_size = [200, 200, 200];
  109. wedge_cut_offset = min_edge_height + (sin(angle) * outer_size.x / 2.0) / cos(angle);
  110. wedge_cut2_offset = (inner_hole_size.x) / sin(90 - angle) / 2.0 + wall_thickness.x;
  111.  
  112.  
  113. epsilon = 0.001;
  114. print_angle = rotate_for_printing ? angle : 0;
  115. flip_angle = mount_door_side == 0 ? 0 : 180;
  116.  
  117. rotate(flip_angle, [0, 0, 1])
  118. rotate(print_angle, [0, 1, 0]) { // for printing without supports
  119. difference() {
  120. // shell
  121. translate([0, 0, -depth]) {
  122. linear_extrude(height = depth) {
  123. offset(r = corner_radius) {
  124. square(outer_size - [corner_radius, corner_radius] * 2.0, center = true);
  125. }
  126. }
  127. }
  128.  
  129. translate([0, 0, -lip_height]) {
  130.  
  131. // inner lip cut
  132. color("red")
  133. linear_extrude(height = lip_height + epsilon) {
  134. offset(r = corner_radius) {
  135. square(inner_size - [corner_radius, corner_radius] * 2.0, center = true);
  136. }
  137. }
  138.  
  139.  
  140. // inner chamfer cut
  141. color("purple")
  142. translate([0, 0, epsilon]) {
  143. mirror([0, 0, 1]) {
  144. linear_extrude(height = inner_depth, scale = inner_bottom_scale) {
  145. offset(r = corner_radius) {
  146. square(inner_size - [corner_radius, corner_radius] * 2.0, center = true);
  147. }
  148. }
  149. }
  150. }
  151.  
  152.  
  153. translate([0, 0, -inner_depth]) {
  154. // inner hole cut
  155. color("orange")
  156. translate([0, 0, -depth - epsilon]) {
  157. linear_extrude(height = depth + epsilon * 3) {
  158. offset(r = inner_hole_corner_radius) {
  159. square(inner_hole_size - [inner_hole_corner_radius, inner_hole_corner_radius] * 2.0, center = true);
  160. }
  161. }
  162. }
  163.  
  164. // screw hole cut
  165. screw_hole(offset = [0, screw_hole_offset, 0]);
  166. screw_hole(offset = [0, -screw_hole_offset, 0]);
  167.  
  168.  
  169. }
  170. }
  171.  
  172. // bottom hole and slit
  173. color("green") {
  174. rotate(90, [1, 0, 0])
  175. mirror([1, 0, 0])
  176. mirror([0, 0, 1])
  177. access_holes();
  178.  
  179. rotate(90, [1, 0, 0])
  180. access_holes();
  181.  
  182. // if (mount_door_side == 0) {
  183. // rotate(90, [1, 0, 0])
  184. // mirror([1, 0, 0])
  185. // mirror([0, 0, 1])
  186. // access_holes();
  187. // } else {
  188. // rotate(90, [1, 0, 0])
  189. // access_holes();
  190. // }
  191. }
  192.  
  193. // Siding Angle Cut
  194. color("grey") {
  195. cube(wedge_cut_size);
  196. }
  197.  
  198. // wedge cut
  199. color("magenta")
  200. mirror([0, 0, 1])
  201. translate([0, 0, wedge_cut_offset + siding_extra_offset])
  202. rotate(angle, [0, 1, 0])
  203. rotate(siding_angle, [1,0,0])
  204. translate([- wedge_cut_size.x / 2.0, - wedge_cut_size.y / 2.0, 0])
  205. cube(wedge_cut_size, center = false);
  206.  
  207. // wedge cut 2
  208. if (trim_back_edge) {
  209. color("red")
  210. mirror([0, 0, 1])
  211. translate([0, 0, wedge_cut_offset])
  212. rotate(angle - 90, [0, 1, 0])
  213. translate([0, 0, wedge_cut2_offset])
  214. translate([- wedge_cut_size.x / 2.0, - wedge_cut_size.y / 2.0, 0])
  215. cube(wedge_cut_size, center = false);
  216. }
  217. }
  218. }
  219.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement