import cadquery as cq from cadquery.occ_impl.exporters import * from ocp_vscode import show pipe_diam = 25.1 clip_thickness = 5 clip_gap = 1.5 clip_height = 12 clip_holes_diam = 4.1 total_thickness = 15 holder_height = 25 # Create the ring by defining two concentric circles and extruding them clip = ( cq.Workplane("XY") # Start in the XY plane .circle(pipe_diam/2) .circle(pipe_diam/2+clip_thickness) .extrude(total_thickness) # Extrude to the specified height ) clip_with_holes = ( clip .faces(">Z") .workplane() .rect(pipe_diam+(clip_thickness+clip_height)*2, clip_gap+clip_thickness*2) .extrude(-total_thickness) .faces(">Y") .workplane(origin=(pipe_diam/2+clip_thickness+clip_height/2, 0, total_thickness/2)) .circle(clip_holes_diam/2) .cutThruAll() .faces(">Y") .workplane(origin=(-(pipe_diam/2+clip_thickness+clip_height/2), 0, total_thickness/2)) .circle(clip_holes_diam/2) .cutThruAll() ) clip_with_ends = clip.union( clip_with_holes ) clip_with_gap = ( clip_with_ends .faces(">Z") .workplane(centerOption="CenterOfMass") .rect(pipe_diam+(clip_thickness+clip_height)*2, clip_gap) .cutThruAll() .circle(pipe_diam/2) .cutThruAll() ) result = clip_with_gap.union( clip_with_gap .faces(">X") .workplane(origin=(0, (clip_thickness + clip_gap)/2, total_thickness/2)) .rect(clip_thickness, total_thickness) .extrude(holder_height) ).fillet(1) show(result) # export the box as a STEP file with open("/home/sgruen/Dokumente/cadquery/mill-endstop.step", "w") as fp: cq.exporters.exportShape(result, ExportTypes.STEP, fp)