endstop_plate.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import *
  3. from ocp_vscode import show
  4. center_width = 18
  5. side_height = 14
  6. center_height = 30
  7. thickness = 4
  8. shift = 2
  9. center_hole_diam = 2.2
  10. center_hole_dist = 9.7
  11. center_hole_shift = center_width/2
  12. side_hole_diam = 3.1
  13. center = cq.Workplane("XY").box(center_width, center_height, thickness)
  14. side = (
  15. center.
  16. faces(">Y")
  17. .workplane(origin=(0,0,shift))
  18. .rect(center_width, thickness)
  19. .extrude(side_height)
  20. )
  21. side_copy = side.mirror("XZ")
  22. result = center.union(side).union(side_copy)
  23. result = (
  24. result.faces(">Z")
  25. .workplane()
  26. .rect(center_width/2,center_height+side_height, forConstruction=True)
  27. .vertices()
  28. .circle(side_hole_diam/2)
  29. .cutThruAll()
  30. )
  31. result = (
  32. result.faces("<Z")
  33. .workplane()
  34. .rect(center_hole_shift,center_hole_dist,forConstruction=True)
  35. .vertices(">X")
  36. .circle(center_hole_diam/2)
  37. .cutThruAll()
  38. ).chamfer(0.5)
  39. show(result)
  40. # export the box as a STEP file
  41. with open("/home/sgruen/Dokumente/cadquery/endstop_plate.step", "w") as fp:
  42. cq.exporters.exportShape(result, ExportTypes.STEP, fp)