spacer.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import ExportTypes
  3. from ocp_vscode import show, show_object
  4. ###### Parameter #####
  5. a_thick = 1.7
  6. a_diam = 3.2
  7. a_gap_width = 1
  8. overhang_a_width = a_gap_width /2 * 0.9
  9. overhang_a_height = 3
  10. b_thick = 4.2
  11. b_diam = 2.8
  12. b_gap_width = a_gap_width
  13. overhang_b_width = b_gap_width /2 * 0.98
  14. overhang_b_height = overhang_a_height
  15. thick_eps = 0.1
  16. space_height = 2.5
  17. space_diam = 7
  18. overhang_top = 0.5
  19. print_height = 3
  20. spacer = cq.Workplane("XY").cylinder(space_height, space_diam/2)
  21. clip_a = (
  22. spacer.faces(">Z").workplane()
  23. .circle(a_diam/2-thick_eps).extrude(a_thick, combine=False)
  24. .faces(">Z").workplane()
  25. .circle(a_diam/2+overhang_a_width).workplane(offset=overhang_a_height+thick_eps)
  26. .circle(overhang_top).loft()
  27. .faces(">Z").workplane()
  28. .rect(a_gap_width, 100)
  29. .cutThruAll()
  30. )
  31. clip_b = (
  32. spacer.faces("<Z").workplane()
  33. .circle(b_diam/2-thick_eps).extrude(b_thick, combine=False)
  34. .faces("<Z").workplane()
  35. .circle(b_diam/2+overhang_b_width).workplane(offset=overhang_b_height+thick_eps)
  36. .circle(overhang_top).loft()
  37. .faces("<Z").workplane()
  38. .rect(b_gap_width, 100)
  39. .cutThruAll()
  40. )
  41. spacer = spacer.union(clip_a).union(clip_b)
  42. spacer_cut = spacer.cut(cq.Workplane("XY").box(100, print_height, 100))
  43. spacer = spacer.cut(spacer_cut)
  44. ############
  45. show_object(spacer)
  46. with open(r"/home/sgruen/Dokumente/bodenplatte/spacer.step", "w") as fp:
  47. cq.exporters.exportShape(spacer, ExportTypes.STEP, fp)