feeder.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import ExportTypes
  3. from ocp_vscode import show, show_object
  4. twist_dist = 170
  5. shift = 40
  6. down_shift = 10
  7. height = 25
  8. width = 70
  9. thickness = 1
  10. adapter_legth = 25
  11. stopper_cut_length=20
  12. eps=0.1
  13. pts = [
  14. (0, 0),
  15. (0, width),
  16. (height, width),
  17. (height, width + thickness),
  18. (-thickness, width + thickness),
  19. (-thickness, -thickness),
  20. (height, -thickness),
  21. (height, 0),
  22. (0, 0),
  23. ]
  24. # Sweep a circle from diameter 2.0 to diameter 1.0 to diameter 2.0 along X axis length 10.0 + 10.0
  25. sweep = (
  26. cq.Workplane("ZX")
  27. .polyline(pts).close()
  28. .workplane(offset=twist_dist/3)
  29. .center(-down_shift/3, shift/3)
  30. .transformed(rotate=(-30, 0, 0))
  31. .polyline(pts).close()
  32. .workplane(offset=twist_dist/3)
  33. .center(-down_shift/3, shift/3)
  34. .transformed(rotate=(-30, 0, 0))
  35. .polyline(pts).close()
  36. .workplane(offset=twist_dist/3)
  37. .center(-down_shift/3, shift/3)
  38. .transformed(rotate=(-30, 0, 0))
  39. .polyline(pts).close()
  40. .loft()
  41. )#.faces("<Y or >X").shell(thickness)
  42. extended = (
  43. sweep.faces(">X")
  44. .extrude(adapter_legth,combine=False)
  45. )
  46. stopper_wall=extended.faces(">X").workplane(centerOption="CenterOfBoundBox").box(width+2*thickness,adapter_legth+thickness,thickness,combine=False)
  47. stopper_wall=extended.union(stopper_wall)
  48. cutout=(
  49. stopper_wall.faces(">X")
  50. .workplane(centerOption="CenterOfBoundBox")
  51. .center(0,thickness/2)
  52. .rect(width+2*thickness-stopper_cut_length,adapter_legth)
  53. .cutBlind(-thickness-eps)
  54. )
  55. extended_cut=cutout.faces(">Y").workplane(centerOption="CenterOfBoundBox").circle(10).cutBlind(until=-80)
  56. # Translate the resulting solids so that they do not overlap and display them left to right
  57. result = extended_cut.union(sweep)
  58. show_object(result)
  59. with open(r"cell_measure_robot/feeder.step", "w") as fp:
  60. cq.exporters.exportShape(result, ExportTypes.STEP, fp)