| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import cadquery as cq
- from ocp_vscode import show, show_object
- from cadquery.occ_impl.exporters import ExportTypes
- rows = 19
- cols = 6
- row_dist = 90
- col_dist = 176
- cut_depth = 10
- center_x = -464.62
- center_y = 130
- hole_diam = 2.5
- hole_width = 160
- hole_height = 84
- ps_diam = 3
- duct_diam = 11
- num_per_powersupply = 3
- mountingplate = cq.importers.importStep("/home/sgruen/Dokumente/Montageplatte/mountingplate.step")
- holes = (
- cq.Workplane(origin=(center_x,center_y,0))
- .center(hole_width/2, -hole_height/2)
- .circle(hole_diam/2)
- .center(-hole_width/2, 0)
- .circle(hole_diam/2)
- .center(-hole_width/2, 0)
- .circle(hole_diam/2)
- .center(0, hole_height)
- .circle(hole_diam/2)
- .center(hole_width/2, 0)
- .circle(hole_diam/2)
- .center(hole_width/2, 0)
- .circle(hole_diam/2)
- .extrude(-cut_depth)
- )
- power_supply = (
- cq.Workplane(origin=(center_x,center_y,0))
- .center(hole_width/2, -hole_height/2+10)
- .circle(ps_diam/2)
- .center(-152.5, 85)
- .circle(ps_diam/2)
- .extrude(-cut_depth)
- )
- duct = (
- cq.Workplane(origin=(center_x,center_y,0))
- .circle(duct_diam/2)
- .extrude(-cut_depth)
- )
- mountingplate_holes = mountingplate
- for row in range(rows):
- for col in range(cols):
- y_offset = row * row_dist
- x_offset = col * col_dist
- hole_negative = holes.translate((x_offset, y_offset, 0))
- mountingplate_holes = mountingplate_holes.cut(hole_negative)
- duct_negative = duct.translate((x_offset, y_offset, 0))
- mountingplate_holes = mountingplate_holes.cut(duct_negative)
- if (col * rows + row) % num_per_powersupply is num_per_powersupply-1:
- ps_negative = power_supply.translate((x_offset, y_offset, 0))
- mountingplate_holes = mountingplate_holes.cut(ps_negative)
- # show_object(mountingplate_holes, name="mountingplate")
- with open(f"mountingplate_holes.step", "w") as fp:
- cq.exporters.exportShape(mountingplate_holes, ExportTypes.STEP, fp)
|