ソースを参照

added polyline instead of rect

Silas Gruen 10 ヶ月 前
コミット
51432cfc4c
1 ファイル変更33 行追加16 行削除
  1. 33 16
      cell_measure_robot/feeder.py

+ 33 - 16
cell_measure_robot/feeder.py

@@ -3,8 +3,8 @@ from cadquery.occ_impl.exporters import ExportTypes
 
 from ocp_vscode import show, show_object
 
-twist_dist = 150
-shift = 50
+twist_dist = 170
+shift = 40
 down_shift = 10
 height = 25
 width = 70
@@ -13,42 +13,59 @@ adapter_legth = 25
 stopper_cut_length=20
 eps=0.1
 
+pts = [
+    (0, 0),
+    (0, width),
+    (height, width),
+    (height, width + thickness),
+    (-thickness, width + thickness),
+    (-thickness, -thickness),
+    (height, -thickness),
+    (height, 0),
+    (0, 0),
+]
+
 # Sweep a circle from diameter 2.0 to diameter 1.0 to diameter 2.0 along X axis length 10.0 + 10.0
 sweep = (
     cq.Workplane("ZX")
-    .rect(height,width)
+    .polyline(pts).close()
     .workplane(offset=twist_dist/3)
     .center(-down_shift/3, shift/3)
     .transformed(rotate=(-30, 0, 0))
-    .rect(height,width)
+    .polyline(pts).close()
     .workplane(offset=twist_dist/3)
     .center(-down_shift/3, shift/3)
     .transformed(rotate=(-30, 0, 0))
-    .rect(height,width)
+    .polyline(pts).close()
     .workplane(offset=twist_dist/3)
     .center(-down_shift/3, shift/3)
     .transformed(rotate=(-30, 0, 0))
-    .rect(height,width)
+    .polyline(pts).close()
     .loft()
-).faces("<Y or >X").shell(thickness)
+)#.faces("<Y or >X").shell(thickness)
 
 extended = (
     sweep.faces(">X")
     .extrude(adapter_legth,combine=False)
-  
 )
-cutextendedtop = extended.faces(">Z").workplane(centerOption="CenterOfBoundBox").rect(adapter_legth,width).cutBlind(until=-thickness-eps)
-stopper_wall=cutextendedtop.faces(">X").workplane(centerOption="CenterOfBoundBox").box(width+2*thickness,adapter_legth+2*thickness,thickness,combine=False).edges("|X").fillet(thickness)
-stopper_wall=cutextendedtop.union(stopper_wall)
-cutout=stopper_wall.faces(">X").workplane(centerOption="CenterOfBoundBox").rect(width-stopper_cut_length,adapter_legth+2*thickness).cutBlind(-thickness-eps)
+
+stopper_wall=extended.faces(">X").workplane(centerOption="CenterOfBoundBox").box(width+2*thickness,adapter_legth+thickness,thickness,combine=False)
+stopper_wall=extended.union(stopper_wall)
+cutout=(
+    stopper_wall.faces(">X")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center(0,thickness/2)
+    .rect(width+2*thickness-stopper_cut_length,adapter_legth)
+    .cutBlind(-thickness-eps)
+)
 
 extended_cut=cutout.faces(">Y").workplane(centerOption="CenterOfBoundBox").circle(10).cutBlind(until=-80)
 # Translate the resulting solids so that they do not overlap and display them left to right
 
+result = extended_cut.union(sweep)
 
-
-show_object(extended_cut)
+show_object(result)
 
 
-with open(r"cadquery_files/cell_measure_robot/feeder.step", "w") as fp:
-   cq.exporters.exportShape(extended, ExportTypes.STEP, fp)
+with open(r"cell_measure_robot/feeder.step", "w") as fp:
+   cq.exporters.exportShape(result, ExportTypes.STEP, fp)