Revolve an arc to form a patch surface

Revolve an arc to form a patch surface

Anonymous
Not applicable
1,183 Views
6 Replies
Message 1 of 7

Revolve an arc to form a patch surface

Anonymous
Not applicable

Capture.PNG

Hi everyone,

I'm trying to revolve an arc around an axis (picture above) to form a patch surface of a half sphere. I tried to create the revolve feature using profile, but since the arc isn't a profile, I created an ObjectCollection for it. But I got the following error:

 

RunTimeError: 3: invalid profile(s) for Revolve Feature.

 

Anyone can advise how to revolve an arc to form a patch surface? Below is my code: 

        # Create the axis of rotation and the arc
        sketch3 = rootComp.sketches.add(rootComp.yZConstructionPlane)
        lines = sketch3.sketchCurves.sketchLines
        axis = lines.addByTwoPoints(adsk.core.Point3D.create(-5.5,2.3,0), adsk.core.Point3D.create(-5.5,8,0))
         
        arcs = sketch3.sketchCurves.sketchArcs
        center = adsk.core.Point3D.create(-5.5,2.3,0)
        start = adsk.core.Point3D.create(-5.5,9.3,0)
        ang = math.pi
        arc = arcs.addByCenterStartSweep(center, start, ang)  
        
        # Create a revolve patch
        prof = adsk.core.ObjectCollection.create()
        prof.add(sketch3.sketchCurves.item(0))
        revolves = rootComp.features.revolveFeatures
        revInput = revolves.createInput(prof, axis, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        revInput.setAngleExtent(True, math.pi/4)

        revInput.isSolid = False      
        revolves.add(revInput)

Thank you!!

 

0 Likes
1,184 Views
6 Replies
Replies (6)
Message 2 of 7

goyals
Autodesk
Autodesk

I think problem is you arc is not closed hence it is not a profile that is why API fails to create revolve. If you close it then it might work. But I know UI allows to choose open arc curves as profile to create revolve.

 

I am not sure if there is any workaround available other than closing curve.



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 3 of 7

BrianEkins
Mentor
Mentor

You should be able to use the createOpenProfile method on the Component object to create a profile of the arc.  However, I wrote a little test case and there are some problems either with the profile or with the revolve functionality.  The code below successfully creates a profile from the arc and extrudes it but if you change the "if True:" statement to "if False:" then it attempts to create a revolve feature and fails.  It does end up creating a revolve in the timeline but when you edit it you'll see the arc and the line were included in the profile which caused it to fail.

 

I then tried to use the API to examine the profile that was created to see if it actually contained both the arc and line but the API is failing to return information for an open profile.  Both of these would seem to be a bug in the API because they should be working.  Maybe Shyam can take a look.

 

def run(context):
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent
        
        sk = root.sketches.add(root.xYConstructionPlane)
        arcs = sk.sketchCurves.sketchArcs
        arc = arcs.addByCenterStartSweep(adsk.core.Point3D.create(0,0,0),
                                         adsk.core.Point3D.create(10,0,0),
                                         math.pi * 0.4)
                                                               
        prof = root.createOpenProfile(arc, False)
        
        if True:
            extrudeInput = root.features.extrudeFeatures.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
            extrudeInput.isSolid = False
            extrudeInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(10))
            extrude = root.features.extrudeFeatures.add(extrudeInput)
        else:
            centerLine = sk.sketchCurves.sketchLines.addByTwoPoints(adsk.core.Point3D.create(0,0,0),
                                                                    adsk.core.Point3D.create(0,10,0))                        
            revolveInput = root.features.revolveFeatures.createInput(prof, centerLine, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
            revolveInput.isSolid = False           
            revolve = root.features.revolveFeatures.add(revolveInput)
    except:
        app = adsk.core.Application.get()
        ui = app.userInterface
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 4 of 7

goyals
Autodesk
Autodesk

@BrianEkins I am able to reproduce both the issues and will take a look. Thanks for taking a look.



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 5 of 7

Anonymous
Not applicable

Thank you. Yes, for now I closed the arc to form a closed profile and it works to create the revolve. 

0 Likes
Message 6 of 7

Anonymous
Not applicable

Hi Brain,

 

That's interesting. Looking forward to hearing the latest update on this method.

0 Likes
Message 7 of 7

saurabh.singhKD42F
Autodesk
Autodesk

@BrianEkins , your test case fails because the revolve angle is not given to revolveInput. It works fine on adding the following line to the script - 

revolveInput.setAngleExtent(True, adsk.core.ValueInput.createByReal(math.pi))Revolve.png

0 Likes