mountingplate.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. thickness = 10
  9. default_dist_x = 550.75
  10. default_dist_y = 208.75
  11. result_dist_x = 4.88
  12. result_dist_y = 52.85
  13. ps_diam = 3
  14. duct_diam = 11
  15. num_per_powersupply = 3
  16. mountingplate = cq.importers.importStep("/home/sgruen/Dokumente/mountingplate.step")
  17. holes_dxf = cq.importers.importDXF("/home/sgruen/Dokumente/Strom_TestLader_V1.1_edit_2.dxf")
  18. power_supply = (
  19. cq.Workplane()
  20. .center(-384.62, 65.85)
  21. .circle(ps_diam/2)
  22. .center(-152.5, 85)
  23. .circle(ps_diam/2)
  24. .extrude(-thickness)
  25. )
  26. duct = (
  27. cq.Workplane()
  28. .center(-464.62, 94.85)
  29. .circle(duct_diam/2)
  30. .extrude(-thickness)
  31. )
  32. holes_dxf = holes_dxf.translate((result_dist_x-default_dist_x, result_dist_y-default_dist_y, 0))
  33. mountingplate_holes = mountingplate
  34. for row in range(rows):
  35. for col in range(cols):
  36. y_offset = row * row_dist
  37. x_offset = col * col_dist
  38. holes_moved = holes_dxf.translate((x_offset, y_offset, 0))
  39. hole_negative = holes_moved.extrude(-thickness)
  40. mountingplate_holes = mountingplate_holes.cut(hole_negative)
  41. duct_negative = duct.translate((x_offset, y_offset, 0))
  42. mountingplate_holes = mountingplate_holes.cut(duct_negative)
  43. if (col * rows + row) % num_per_powersupply is num_per_powersupply-1:
  44. ps_negative = power_supply.translate((x_offset, y_offset, 0))
  45. mountingplate_holes = mountingplate_holes.cut(ps_negative)
  46. # show_object(mountingplate_holes, name="mountingplate")
  47. with open(f"mountingplate_holes.step", "w") as fp:
  48. cq.exporters.exportShape(mountingplate_holes, ExportTypes.STEP, fp)