mountingplate.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import cadquery as cq
  2. from ocp_vscode import show, show_object
  3. from cadquery.occ_impl.exporters import ExportTypes
  4. rows = 19
  5. cols = 6
  6. row_dist = 90
  7. col_dist = 176
  8. cut_depth = 10
  9. center_x = -464.62
  10. center_y = 130
  11. hole_diam = 2.5
  12. hole_width = 160
  13. hole_height = 84
  14. ps_diam = 3
  15. duct_diam = 11
  16. num_per_powersupply = 3
  17. mountingplate = cq.importers.importStep("/home/sgruen/Dokumente/Montageplatte/mountingplate.step")
  18. holes = (
  19. cq.Workplane(origin=(center_x,center_y,0))
  20. .center(hole_width/2, -hole_height/2)
  21. .circle(hole_diam/2)
  22. .center(-hole_width/2, 0)
  23. .circle(hole_diam/2)
  24. .center(-hole_width/2, 0)
  25. .circle(hole_diam/2)
  26. .center(0, hole_height)
  27. .circle(hole_diam/2)
  28. .center(hole_width/2, 0)
  29. .circle(hole_diam/2)
  30. .center(hole_width/2, 0)
  31. .circle(hole_diam/2)
  32. .extrude(-cut_depth)
  33. )
  34. power_supply = (
  35. cq.Workplane(origin=(center_x,center_y,0))
  36. .center(hole_width/2, -hole_height/2+10)
  37. .circle(ps_diam/2)
  38. .center(-152.5, 85)
  39. .circle(ps_diam/2)
  40. .extrude(-cut_depth)
  41. )
  42. duct = (
  43. cq.Workplane(origin=(center_x,center_y,0))
  44. .circle(duct_diam/2)
  45. .extrude(-cut_depth)
  46. )
  47. mountingplate_holes = mountingplate
  48. for row in range(rows):
  49. for col in range(cols):
  50. y_offset = row * row_dist
  51. x_offset = col * col_dist
  52. hole_negative = holes.translate((x_offset, y_offset, 0))
  53. mountingplate_holes = mountingplate_holes.cut(hole_negative)
  54. duct_negative = duct.translate((x_offset, y_offset, 0))
  55. mountingplate_holes = mountingplate_holes.cut(duct_negative)
  56. if (col * rows + row) % num_per_powersupply is num_per_powersupply-1:
  57. ps_negative = power_supply.translate((x_offset, y_offset, 0))
  58. mountingplate_holes = mountingplate_holes.cut(ps_negative)
  59. # show_object(mountingplate_holes, name="mountingplate")
  60. with open(f"mountingplate_holes.step", "w") as fp:
  61. cq.exporters.exportShape(mountingplate_holes, ExportTypes.STEP, fp)