zellhalter_v2.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import ExportTypes
  3. from ocp_vscode import show, show_object
  4. ###### Parameter #####
  5. cells_per_row = 8
  6. rows = 2
  7. cell_diam = 18.44
  8. cell_length = 65
  9. dist_to_ground = 66.9
  10. space_all = 140
  11. space_single = space_all / (cells_per_row - 1)
  12. space_rows = 33.7
  13. strip_width = 10.2
  14. print_height = 10
  15. wall_thick = 1.5
  16. eps = 0.1
  17. ############
  18. cell_locations = [(x * space_single, y * space_rows) for x in range(0, cells_per_row) for y in range(0, rows)]
  19. strip_locations = [(-cell_diam/4, y * space_rows) for y in range(0, rows)]
  20. cell_base = (
  21. cq.Workplane()
  22. .pushPoints(cell_locations)
  23. .eachpoint(
  24. lambda loc: (
  25. cq.Workplane()
  26. .circle(cell_diam/2 + eps + wall_thick)
  27. .extrude(wall_thick)
  28. .circle(cell_diam/2 + eps)
  29. .circle(cell_diam/2 + eps + wall_thick)
  30. .extrude(print_height)
  31. .val()
  32. .located(loc)
  33. )
  34. )
  35. )
  36. strips_cut = (
  37. cq.Workplane()
  38. .pushPoints(strip_locations)
  39. .eachpoint(
  40. lambda loc: (
  41. cq.Workplane()
  42. .rect(space_all + cell_diam/2, strip_width, centered=(False, True))
  43. .extrude(print_height)
  44. .val()
  45. .located(loc)
  46. )
  47. )
  48. )
  49. strips_wall = (
  50. cq.Workplane()
  51. .pushPoints(strip_locations)
  52. .eachpoint(
  53. lambda loc: (
  54. cq.Workplane()
  55. .rect(space_all, strip_width, centered=(False, True))
  56. .center(-wall_thick, 0)
  57. .rect(space_all+ 2*wall_thick, strip_width + 2*wall_thick, centered=(False, True))
  58. .extrude(print_height)
  59. .val()
  60. .located(loc)
  61. )
  62. )
  63. )
  64. cell_base_hull = (
  65. cq.Workplane()
  66. .pushPoints(cell_locations)
  67. .eachpoint(
  68. lambda loc: (
  69. cq.Workplane()
  70. .circle(cell_diam/2 + eps + wall_thick)
  71. .extrude(print_height)
  72. .val()
  73. .located(loc)
  74. )
  75. )
  76. )
  77. strips_wall_cut = strips_wall.cut(cell_base_hull)
  78. cell_base_with_wall = cell_base.union(strips_wall_cut).cut(strips_cut)
  79. show_object(cell_base)
  80. with open(r"/home/sgruen/Dokumente/bodenplatte/zellhalter_v2.step", "w") as fp:
  81. cq.exporters.exportShape(cell_base, ExportTypes.STEP, fp)