mountingplate.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. center_x = -464.62
  14. center_y = 94.85
  15. hole_diam = 2.5
  16. hole_width = 160
  17. hole_height = 84
  18. ps_diam = 3
  19. duct_diam = 11
  20. num_per_powersupply = 3
  21. mountingplate = cq.importers.importStep("/home/sgruen/Dokumente/mountingplate.step")
  22. # holes_dxf = cq.importers.importDXF("/home/sgruen/Dokumente/Strom_TestLader_V1.1_edit_2.dxf")
  23. holes = (
  24. cq.Workplane(origin=(center_x,center_y,0))
  25. .center(hole_width/2, -hole_height/2)
  26. .circle(hole_diam/2)
  27. .center(-hole_width/2, 0)
  28. .circle(hole_diam/2)
  29. .center(-hole_width/2, 0)
  30. .circle(hole_diam/2)
  31. .center(0, hole_height)
  32. .circle(hole_diam/2)
  33. .center(hole_width/2, 0)
  34. .circle(hole_diam/2)
  35. .center(hole_width/2, 0)
  36. .circle(hole_diam/2)
  37. .extrude(-thickness)
  38. )
  39. power_supply = (
  40. cq.Workplane(origin=(center_x,center_y,0))
  41. .center(hole_width/2, -hole_height/2+10)
  42. .circle(ps_diam/2)
  43. .center(-152.5, 85)
  44. .circle(ps_diam/2)
  45. .extrude(-thickness)
  46. )
  47. duct = (
  48. cq.Workplane(origin=(center_x,center_y,0))
  49. .circle(duct_diam/2)
  50. .extrude(-thickness)
  51. )
  52. # holes_dxf = holes_dxf.translate((result_dist_x-default_dist_x, result_dist_y-default_dist_y, 0))
  53. mountingplate_holes = mountingplate
  54. for row in range(rows):
  55. for col in range(cols):
  56. y_offset = row * row_dist
  57. x_offset = col * col_dist
  58. hole_negative = holes.translate((x_offset, y_offset, 0))
  59. mountingplate_holes = mountingplate_holes.cut(hole_negative)
  60. duct_negative = duct.translate((x_offset, y_offset, 0))
  61. mountingplate_holes = mountingplate_holes.cut(duct_negative)
  62. if (col * rows + row) % num_per_powersupply is num_per_powersupply-1:
  63. ps_negative = power_supply.translate((x_offset, y_offset, 0))
  64. mountingplate_holes = mountingplate_holes.cut(ps_negative)
  65. # show_object(mountingplate_holes, name="mountingplate")
  66. with open(f"mountingplate_holes.step", "w") as fp:
  67. cq.exporters.exportShape(mountingplate_holes, ExportTypes.STEP, fp)