bltouch_holder.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import *
  3. from ocp_vscode import show
  4. attach_hole_diam = 5.1
  5. attach_hole_dist = 50
  6. thick = 3
  7. flap_width = 15
  8. flap_len = attach_hole_dist + 2 * attach_hole_diam
  9. holder_width = 26.2
  10. holder_depth = 10.5 + thick
  11. bl_hole_diam = 3.85
  12. bl_hole_dist = 21.4 - bl_hole_diam
  13. flap = (
  14. cq.Workplane("XY")
  15. .workplane()
  16. .rect(flap_len, flap_width)
  17. .extrude(thick)
  18. )
  19. flap = (
  20. flap.faces(">Z")
  21. .workplane()
  22. .center(attach_hole_dist/2, 0)
  23. .circle(attach_hole_diam/2)
  24. .center(-attach_hole_dist, 0)
  25. .circle(attach_hole_diam/2)
  26. .cutThruAll()
  27. # .edges("|Z")
  28. # .fillet(2)
  29. )
  30. angle = (
  31. flap.faces(">X")
  32. .workplane(centerOption="CenterOfBoundBox")
  33. .center(0, -thick/2)
  34. .rect(holder_width, holder_depth, centered=(True,False))
  35. .extrude(thick)
  36. .faces(">X")
  37. .workplane(centerOption="CenterOfBoundBox")
  38. .center(-bl_hole_dist/2, 0)
  39. .circle(bl_hole_diam/2)
  40. .center(bl_hole_dist,0)
  41. .circle(bl_hole_diam/2)
  42. .cutThruAll()
  43. .edges("|X")
  44. .fillet(1)
  45. .faces("<X")
  46. .fillet(1)
  47. )
  48. show(angle)
  49. # export the box as a STEP file
  50. with open("/home/sgruen/Dokumente/cadquery/bltouch_holder.step", "w") as fp:
  51. cq.exporters.exportShape(angle, ExportTypes.STEP, fp)