| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import cadquery as cq
- from cadquery.occ_impl.exporters import *
- from ocp_vscode import show
- center_width = 18
- side_height = 14
- center_height = 30
- thickness = 4
- shift = 2
- center_hole_diam = 2.2
- center_hole_dist = 9.7
- center_hole_shift = center_width/2
- side_hole_diam = 3.1
- center = cq.Workplane("XY").box(center_width, center_height, thickness)
- side = (
- center.
- faces(">Y")
- .workplane(origin=(0,0,shift))
- .rect(center_width, thickness)
- .extrude(side_height)
- )
- side_copy = side.mirror("XZ")
- result = center.union(side).union(side_copy)
- result = (
- result.faces(">Z")
- .workplane()
- .rect(center_width/2,center_height+side_height, forConstruction=True)
- .vertices()
- .circle(side_hole_diam/2)
- .cutThruAll()
- )
- result = (
- result.faces("<Z")
- .workplane()
- .rect(center_hole_shift,center_hole_dist,forConstruction=True)
- .vertices(">X")
- .circle(center_hole_diam/2)
- .cutThruAll()
- ).chamfer(0.5)
- show(result)
- # export the box as a STEP file
- with open("/home/sgruen/Dokumente/cadquery/endstop_plate.step", "w") as fp:
- cq.exporters.exportShape(result, ExportTypes.STEP, fp)
|