zellhalter_v3_injection.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import ExportTypes
  3. from ocp_vscode import show, show_object
  4. # Zellhalter für Injection Moulding
  5. ###### Parameter #####
  6. cells_per_row = 8
  7. rows = 2
  8. cell_diam = 18.44
  9. cell_length = 65
  10. dist_to_ground = 66.9
  11. space_all = 140
  12. space_single = space_all / (cells_per_row - 1)
  13. space_rows = 33.7
  14. dist_segments = 57.5
  15. strip_width = 10.4
  16. print_height = 15
  17. wall_thick = 1.7
  18. eps = 0.15
  19. hole_diam = 2.4
  20. hole_depth = 10
  21. board_connector_length = dist_to_ground + wall_thick
  22. lip_width = 1.5
  23. lip_thick = 1.5
  24. ############
  25. cell_locs = [(x * space_single, y * space_rows) for x in range(0, cells_per_row) for y in range(0, rows)]
  26. strip_locs = [(-cell_diam/4, y * space_rows) for y in range(0, rows)]
  27. row_connector_locs = [(x * space_single * 2, (y + 0.5) * space_rows) for x in range(0, int(cells_per_row/2)) for y in range(0, rows-1)]
  28. cell_edge = cell_diam/2 - 1.5
  29. board_con_locs_with_rot = [
  30. ((-.5 * space_single, -cell_edge), 0),
  31. ((-.5 * space_single, space_rows + cell_edge), 180),
  32. ((5.5 * space_single, cell_edge), 180),
  33. ((5.5 * space_single, space_rows - cell_edge), 0),
  34. ]
  35. # Zellkreise
  36. cell_base = (
  37. cq.Workplane()
  38. .pushPoints(cell_locs)
  39. .eachpoint(
  40. lambda loc: (
  41. cq.Workplane()
  42. .circle(cell_diam/2 + eps + wall_thick)
  43. .extrude(print_height)
  44. .val()
  45. .located(loc)
  46. )
  47. )
  48. )
  49. # Ausschnitt für die Zellen
  50. cell_cutout = (
  51. cq.Workplane()
  52. .pushPoints(cell_locs)
  53. .eachpoint(
  54. lambda loc: (
  55. cq.Workplane()
  56. .circle(cell_diam/2 + eps)
  57. .extrude(print_height-wall_thick)
  58. .val()
  59. .located(loc)
  60. )
  61. )
  62. )
  63. # Ausschnitt für die Lötfahne
  64. strips_cut = (
  65. cq.Workplane()
  66. .pushPoints(strip_locs)
  67. .eachpoint(
  68. lambda loc: (
  69. cq.Workplane().workplane(offset=print_height-2*wall_thick)
  70. .rect(space_all + cell_diam/2+wall_thick, strip_width, centered=(False, True))
  71. .extrude(wall_thick*2)
  72. .val()
  73. .located(loc)
  74. )
  75. )
  76. )
  77. strips_wall = (
  78. cq.Workplane()
  79. .pushPoints(strip_locs)
  80. .eachpoint(
  81. lambda loc: (
  82. cq.Workplane()
  83. .rect(space_all+ 2*wall_thick, strip_width + 2*wall_thick, centered=(False, True))
  84. .extrude(print_height)
  85. .val()
  86. .located(loc)
  87. )
  88. )
  89. )
  90. base_cutout = cell_base.union(strips_wall).cut(cell_cutout)
  91. row_connectors = (
  92. cq.Workplane()
  93. .pushPoints(row_connector_locs)
  94. .eachpoint(
  95. lambda loc: (
  96. cq.Workplane().workplane(offset=wall_thick)
  97. .rect(wall_thick, space_rows - cell_diam - wall_thick, centered=(False, True))
  98. .extrude(print_height-wall_thick)
  99. .val()
  100. .located(loc)
  101. )
  102. )
  103. )
  104. base_connected = base_cutout.union(row_connectors)
  105. connector_width = hole_diam + wall_thick*2
  106. connector_print_height = print_height+wall_thick/2
  107. board_con = (
  108. cq.Workplane(origin=(0,0,print_height))
  109. .circle(connector_width/2)
  110. .extrude(-connector_print_height)
  111. .faces("<Z")
  112. .chamfer(wall_thick/2)
  113. .faces("<Z")
  114. .workplane()
  115. .circle(connector_width/2-wall_thick/2)
  116. .extrude(board_connector_length-connector_print_height)
  117. .faces("<Z")
  118. .workplane()
  119. .circle(hole_diam/2)
  120. .cutBlind(-hole_depth)
  121. )
  122. # Runde bordconnector mit Loch am Ende
  123. for location, angle in board_con_locs_with_rot:
  124. con = board_con.translate(location)
  125. con = con.rotateAboutCenter((0,0,1), angle)
  126. base_connected = base_connected.union(con)
  127. # Schneide die Lötstreifen aus
  128. base_connected = base_connected.cut(strips_cut)
  129. # Fase and Connectors
  130. test = base_connected.edges("|Z")
  131. # Begrenzungsbox für den gesamten Zellhalter (sonst schneidet man den nächsten Halter)
  132. boundary_box = (
  133. base_connected.workplane(centerOption="CenterOfBoundBox")
  134. .box(1000, dist_segments, 1000,combine=False)
  135. )
  136. base_connected = base_connected.intersect(boundary_box)
  137. show_object(base_connected)
  138. with open(r"zellhalter_v3.step", "w") as fp:
  139. cq.exporters.exportShape(base_connected, ExportTypes.STEP, fp)