将下面进行一个嵌套循环,n添加一个外循环【0,50】,内部的 range依次增加24,n的内部循环是1200/1201,n1的内部循环是1201/1202,依次加一。
用代码块功能插入代码,请勿粘贴截图
-
for n in range(1, 25):
Fill1 = hsf.add_new_fill()
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n}"))
Fill1.add_bound(reference11)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n + 1200}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n + 24}"))
Fill1.add_bound(reference13)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n + 1201}"))
Fill1.add_bound(reference14)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)
for n1 in range(25, 49):
Fill1 = hsf.add_new_fill()
hybridBodies1 = part.hybrid_bodies
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n1}"))
Fill1.add_bound(reference11)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n1 + 1201}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n1 + 24}"))
Fill1.add_bound(reference13)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n1 + 1202}"))
Fill1.add_bound(reference14)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)
#
for n2 in range(49,73):
Fill1 = hsf.add_new_fill()
hybridBodies1 = part.hybrid_bodies
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n2}"))
Fill1.add_bound(reference11)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n2 + 1202}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n2 + 24}"))
Fill1.add_bound(reference13)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n2 + 1203}"))
Fill1.add_bound(reference14)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)
for n3 in range(73, 97):
Fill1 = hsf.add_new_fill()
hybridBodies1 = part.hybrid_bodies
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n3}"))
Fill1.add_bound(reference11)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n3 + 1203}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n3 + 24}"))
Fill1.add_bound(reference13)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n3 + 1204}"))
Fill1.add_bound(reference14)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)
for n4 in range(97, 121):
Fill1 = hsf.add_new_fill()
hybridBodies1 = part.hybrid_bodies
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n4}"))
Fill1.add_bound(reference11)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n4 + 1204}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n4 + 24}"))
Fill1.add_bound(reference13)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n4 + 1205}"))
Fill1.add_bound(reference14)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)
for n5 in range(121, 145):
Fill1 = hsf.add_new_fill()
hybridBodies1 = part.hybrid_bodies
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n5}"))
Fill1.add_bound(reference11)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n5 + 1205}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n5 + 24}"))
Fill1.add_bound(reference13)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n5 + 1206}"))
Fill1.add_bound(reference14)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)
我尝试得结果
for a in range(50):
for n in range(24*a+1, 24*(a+1)+1):
# for n in range(1, 25):
Fill1 = hsf.add_new_fill()
hybridBodies1 = part.hybrid_bodies
hybridBody1 = hb1.item("几何图形集.3")
hybridShape1 = hybridBody1.hybrid_shapes
reference11 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n}"))
Fill1.add_bound(reference11)
reference14 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n + 1200 }"+f"{'a'}"))
Fill1.add_bound(reference14)
reference12 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n + 174}"))
Fill1.add_bound(reference12)
reference13 = part.create_reference_from_object(hybridShape1.item("样条线." + f"{n + 1201 }"+f"{'a'}"))
Fill1.add_bound(reference13)
Fill1.Continuity = 0
hb.append_hybrid_shape(Fill1)