vise_angle.py 718 B

12345678910111213141516171819202122232425262728
  1. import cadquery as cq
  2. from cadquery.occ_impl.exporters import *
  3. from ocp_vscode import show
  4. width = 60
  5. depth = 159
  6. thick = 2
  7. angle_deg = 1
  8. hole_length = 79
  9. hole_width = 43.5
  10. hole_diam = 6
  11. result = (
  12. cq.Workplane("XY")
  13. .workplane(centerOption="CenterOfBoundBox")
  14. .rect(depth,width)
  15. .workplane(offset=thick)
  16. .transformed(rotate=(0, angle_deg, 0))
  17. .rect(depth,width)
  18. .loft()
  19. )
  20. result = result.faces("<Z").workplane().rect(hole_length, hole_width,forConstruction=True).vertices().circle(hole_diam/2).cutThruAll()
  21. show(result)
  22. # export the box as a STEP file
  23. with open("/home/sgruen/Dokumente/cadquery/vise_angle.step", "w") as fp:
  24. cq.exporters.exportShape(result, ExportTypes.STEP, fp)