A below picture is a sample.
I made a body from a surface using Revolve at first(the gray one).
And I want to make a new body(the red one) on the endFace or other faces.
But I don't know the way to make the red body using python API automatically.
How do I write that?
Here's my code to draw the first body. I was able to get the endFace from it, but I didn't know what to do after that....
import adsk.core, adsk.fusion, math, traceback 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; sketch = sketches.add(xyPlane) # Draw a circle. circles = sketch.sketchCurves.sketchCircles circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(10, 0, 0), 2) # Draw a line to use as the axis of revolution. lines = sketch.sketchCurves.sketchLines axisLine = lines.addByTwoPoints(adsk.core.Point3D.create(0, -10, 0), adsk.core.Point3D.create(0, 10, 0)) axisLine2 = lines.addByTwoPoints(adsk.core.Point3D.create(15, -10, 0), adsk.core.Point3D.create(15, 10, 0)) # Get the profile defined by the circle. prof = sketch.profiles.item(0) # Create an revolution input to be able to define the input needed for a revolution # while specifying the profile and that a new component is to be created revolves = rootComp.features.revolveFeatures revInput = revolves.createInput(prof, axisLine, adsk.fusion.FeatureOperations.NewComponentFeatureOperation) # Define that the extent is an angle of pi to get half of a torus. angle = adsk.core.ValueInput.createByReal(math.pi) revInput.setAngleExtent(False, angle) # Create the extrusion. ext = revolves.add(revInput) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Hi miki.
I did it like this.
・・・ ext = revolves.add(revInput) # Get endFace endFace :adsk.fusion.BRepFace = ext.endFaces.item(0) # Create sketch comp = endFace.body.parentComponent sketch2 = comp.sketches.add(endFace) lines2 = sketch2.sketchCurves.sketchLines pnt3D = adsk.core.Point3D axisLine3 = lines2.addByTwoPoints(pnt3D.create(15, -10, 0), pnt3D.create(15, 10, 0)) # Create revolve prof2 = sketch2.profiles.item(0) revolves2 = comp.features.revolveFeatures newBody = adsk.fusion.FeatureOperations.NewBodyFeatureOperation revInput2 = revolves2.createInput(prof2, axisLine3, newBody) angle2 = adsk.core.ValueInput.createByReal(math.pi * 0.75) revInput2.setAngleExtent(False, angle2) ext2 = revolves2.add(revInput2) ・・・
I learned too.
kanndenti, thank you for your reply!
I changed
endFace :adsk.fusion.BRepFace = ext.endFaces.item(0)
to
endFace = ext.endFaces.item(0)
and I was able to make it!
私も日本人の方だなと思っていたのですが、一応英語の方のフォーラムだったので😅
添付の図はサンプルから適当に持ってきたものだったのですが、
Revolveに限らずExtrudeなどで作ったボディの面から新しくボディを作る方法がわからなかったので助かりました。
ありがとうございます!
Can't find what you're looking for? Ask the community or share your knowledge.