how to add bodies created by the Circular pattern function

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello,
I just had create a simple rim by fusion 360 API. I wanted to make a spoke and made bodies of spoke shape as circular pattern. I hope to combine cut with a body of spoke and bodies of spoke shape. But i can't select to bodies of spoke shape. how can i add to bodies of spoke shape using by fusion360 API.
This is my code
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback,math
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xy plane.
sketches = rootComp.sketches;
xyPlane = rootComp.xYConstructionPlane
sketch1 = sketches.add(xyPlane)
sp1 = adsk.core.Point3D.create(24.5, 0, 0)
p2 = adsk.core.Point3D.create(24.5, 0, 0.5)
p3 = adsk.core.Point3D.create(23.2, 0, 2.5)
p4 = adsk.core.Point3D.create(23.2,0,4.5)
p5 = adsk.core.Point3D.create(22,0,6.5)
p6 = adsk.core.Point3D.create(22,0,14.3)
p7 = adsk.core.Point3D.create(23.2,0,16.3)
p8 = adsk.core.Point3D.create(23.2,0,22.7)
p9 = adsk.core.Point3D.create(24.5,0,24.7)
ep10 = adsk.core.Point3D.create(24.5 ,0,25.2)
sp11 = adsk.core.Point3D.create(24, 0, 0)
p12 = adsk.core.Point3D.create(24, 0, 0.5)
p13 = adsk.core.Point3D.create(22.7, 0, 2.5)
p14 = adsk.core.Point3D.create(22.7,0,4.5)
p15 = adsk.core.Point3D.create(21.5,0,6.5)
p16 = adsk.core.Point3D.create(21.5,0,14.3)
p17 = adsk.core.Point3D.create(22.7,0,16.3)
p18 = adsk.core.Point3D.create(22.7,0,22.7)
p19 = adsk.core.Point3D.create(24,0,24.7)
ep20 = adsk.core.Point3D.create(24.0 ,0,25.2)
axisp1 = adsk.core.Point3D.create(0,0,250/10)
axisp2 = adsk.core.Point3D.create(0,0,0)
sketch1_lines = sketch1.sketchCurves.sketchLines;
s1_line1 = sketch1_lines.addByTwoPoints(sp1,p2)
s1_line2 = sketch1_lines.addByTwoPoints(p2,p3)
s1_line3 = sketch1_lines.addByTwoPoints(p3,p4)
s1_line4 = sketch1_lines.addByTwoPoints(p4,p5)
s1_line5 = sketch1_lines.addByTwoPoints(p5,p6)
s1_line6 = sketch1_lines.addByTwoPoints(p6,p7)
s1_line7 = sketch1_lines.addByTwoPoints(p7,p8)
s1_line8 = sketch1_lines.addByTwoPoints(p8,p9)
s1_line9 = sketch1_lines.addByTwoPoints(p9,ep10)
s1_line10 = sketch1_lines.addByTwoPoints(sp11,p12)
s1_line11 = sketch1_lines.addByTwoPoints(p12,p13)
s1_line12 = sketch1_lines.addByTwoPoints(p13,p14)
s1_line13 = sketch1_lines.addByTwoPoints(p14,p15)
s1_line14 = sketch1_lines.addByTwoPoints(p15,p16)
s1_line15 = sketch1_lines.addByTwoPoints(p16,p17)
s1_line16 = sketch1_lines.addByTwoPoints(p17,p18)
s1_line17 = sketch1_lines.addByTwoPoints(p18,p19)
s1_line18 = sketch1_lines.addByTwoPoints(p19,ep20)
s1_line19 = sketch1_lines.addByTwoPoints(ep10,ep20)
s1_line20 = sketch1_lines.addByTwoPoints(sp1,sp11)
sl_axisline = sketch1_lines.addByTwoPoints(axisp1,axisp2)
s1_prof = sketch1.profiles.item(0)
s1_revolves = rootComp.features.revolveFeatures
s1_revInput = s1_revolves.createInput(s1_prof,sl_axisline, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
s1_angle = adsk.core.ValueInput.createByReal(2*math.pi)
s1_revInput.setAngleExtent(False, s1_angle)
s1_ext = s1_revolves.add(s1_revInput)
#sketch2 시작
sketch2 = sketches.add(xyPlane)
disc1 = adsk.core.Point3D.create(0, 0, 25)
disc2 = adsk.core.Point3D.create(6, 0, 25)
disc3 = adsk.core.Point3D.create(0, 0, 16.0)
disc4 = adsk.core.Point3D.create(6, 0, 16)
spk1 = adsk.core.Point3D.create(24,0,24.7)
spk2 = adsk.core.Point3D.create(22.7,0,22.7)
spk3 = adsk.core.Point3D.create(22.7,0,20.178)
spk4 = adsk.core.Point3D.create(0,0,25)
spk5 = adsk.core.Point3D.create(0,0,16)
spk6 = adsk.core.Point3D.create(6,0,25)
spk7 = adsk.core.Point3D.create(6.9994,0,25.2)
spk8 = adsk.core.Point3D.create(14,0,26)
spk9 = adsk.core.Point3D.create(20,0,26)
spk10 = adsk.core.Point3D.create(24,0,24.7)
spk11 = adsk.core.Point3D.create(6,0,16)
spk12 = adsk.core.Point3D.create(7.5,0,20)
spk13 = adsk.core.Point3D.create(15.5,0,22)
spk14 = adsk.core.Point3D.create(15.5,0,22.5)
spk15 = adsk.core.Point3D.create(22.7,0,20.178)
sketch2_lines = sketch2.sketchCurves.sketchLines;
s2_line1 = sketch2_lines.addByTwoPoints(disc1,disc2)
s2_line2 = sketch2_lines.addByTwoPoints(disc3,disc4)
s2_line3 = sketch2_lines.addByTwoPoints(spk1,spk2)
s2_line4 = sketch2_lines.addByTwoPoints(spk2,spk3)
s2_line5 = sketch2_lines.addByTwoPoints(spk4,spk5)
s2_axisline = sketch2_lines.addByTwoPoints(axisp1,axisp2)
s2_spline1 = adsk.core.ObjectCollection.create()
s2_spline1.add(spk6)
s2_spline1.add(spk7)
s2_spline1.add(spk8)
s2_spline1.add(spk9)
s2_spline1.add(spk10)
sketch2.sketchCurves.sketchFittedSplines.add(s2_spline1)
s2_spline2 = adsk.core.ObjectCollection.create()
s2_spline2.add(spk11)
s2_spline2.add(spk12)
s2_spline2.add(spk13)
s2_spline2.add(spk14)
s2_spline2.add(spk15)
sketch2.sketchCurves.sketchFittedSplines.add(s2_spline2)
s2_prof = sketch2.profiles.item(0)
s2_revolves = rootComp.features.revolveFeatures
s2_revInput = s2_revolves.createInput(s2_prof,s2_axisline, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
s2_angle = adsk.core.ValueInput.createByReal(2*math.pi)
s2_revInput.setAngleExtent(False, s2_angle)
s2_ext = s2_revolves.add(s2_revInput)
#sketch3 시작
sketch3 = sketches.add(xyPlane)
c1 = adsk.core.Point3D.create(0, 25.5, 0)
c2 = adsk.core.Point3D.create(0, 0, 0)
c3 = adsk.core.Point3D.create(14.9885, 20.6299, 0)
spk2_1 = adsk.core.Point3D.create(0,7.9631,0)
spk2_2 = adsk.core.Point3D.create(5,14,0)
spk2_3 = adsk.core.Point3D.create(6.7566,24.5316,0)
spk2_4 = adsk.core.Point3D.create(0,25.5,0)
spk2_5 = adsk.core.Point3D.create(7.1645,9.8611,0)
spk2_6 = adsk.core.Point3D.create(11,23,0)
spk2_7 = adsk.core.Point3D.create(14.9885,20.6299,0)
sketch3_lines = sketch3.sketchCurves.sketchLines;
s3_line1 = sketch3_lines.addByTwoPoints(c1,c2)
s3_spline1 = adsk.core.ObjectCollection.create()
s3_spline1.add(spk2_1)
s3_spline1.add(spk2_2)
s3_spline1.add(spk2_3)
s3_spline1.add(spk2_4)
sketch3.sketchCurves.sketchFittedSplines.add(s3_spline1)
s3_prof = sketch3.profiles.item(0)
features = rootComp.features
extrudes = features.extrudeFeatures
extInput = extrudes.createInput(s3_prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Define that the extent is a distance extent of 5 cm.
distance = adsk.core.ValueInput.createByReal(30)
extInput.setDistanceExtent(False, distance)
# Create the extrusion.
s3_ext = extrudes.add(extInput)
s3_body = s3_ext.bodies.item(0)
s3_face = s3_body.faces.item(0)
planes = rootComp.constructionPlanes
planeInput = planes.createInput()
offsetDistance = adsk.core.ValueInput.createByString('0 cm')
planeInput.setByOffset(s3_face, offsetDistance)
plane = planes.add(planeInput)
inputEntites = adsk.core.ObjectCollection.create()
inputEntites.add(s3_body)
mirrorFeatures = features.mirrorFeatures
mirrorInput = mirrorFeatures.createInput(inputEntites, plane)
# Create the mirror feature
mirrorFeature1 = mirrorFeatures.add(mirrorInput)
mirror_body1 = mirrorFeature1.bodies.item(0)
inputEntites.add(mirror_body1)
sketch4 = sketches.add(xyPlane)
sketch4_lines = sketch4.sketchCurves.sketchLines;
s4_line1 = sketch4_lines.addByTwoPoints(spk2_7,spk2_5)
s4_spline1 = adsk.core.ObjectCollection.create()
s4_spline1.add(spk2_5)
s4_spline1.add(spk2_6)
s4_spline1.add(spk2_7)
sketch4.sketchCurves.sketchFittedSplines.add(s4_spline1)
s4_prof = sketch4.profiles.item(0)
features1 = rootComp.features
extrudes1 = features1.extrudeFeatures
extInput1 = extrudes1.createInput(s4_prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Define that the extent is a distance extent of 5 cm.
extInput1.setDistanceExtent(False, distance)
# Create the extrusion.
s4_ext = extrudes1.add(extInput1)
s4_body = s4_ext.bodies.item(0)
s4_face = s4_body.faces.item(1)
planes = rootComp.constructionPlanes
planeInput = planes.createInput()
offsetDistance = adsk.core.ValueInput.createByString('0 cm')
planeInput.setByOffset(s4_face, offsetDistance)
plane = planes.add(planeInput)
inputEntites.add(s4_body)
mirrorFeatures = features.mirrorFeatures
mirrorInput = mirrorFeatures.createInput(inputEntites, plane)
# Create the mirror feature
mirrorFeature2 = mirrorFeatures.add(mirrorInput)
mirror_body2 = mirrorFeature2.bodies.item(0)
inputEntites.add(mirror_body2)
# Get Y axis for circular pattern
ZAxis = rootComp.zConstructionAxis
# Create the input for circular pattern
circularFeats = rootComp.features.circularPatternFeatures
circularFeatInput = circularFeats.createInput(inputEntites, ZAxis)
# Set the quantity of the elements
circularFeatInput.quantity = adsk.core.ValueInput.createByReal(5)
# Set the angle of the circular pattern
circularFeatInput.totalAngle = adsk.core.ValueInput.createByString('360 deg')
# Set symmetry of the circular pattern
circularFeatInput.isSymmetric = False
# Create the circular pattern
circularFeat = circularFeats.add(circularFeatInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))