Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modifying features without recreating them

Message 1 of 6
345 Views, 5 Replies

Modifying features without recreating them

I am trying to modify an extrude feature after it has been created. Specifically, changing the profile of the extrude.


During creation we use ExtrudeFeatureInput to specify the extrude parameters, but when the extrude feature is already created, how do we change the existing feature?


It doesn't work the way I'm trying, maybe there's a way that can work without recreating the body?


This is what I'm trying to do:

extrude = extrudes->itemByName("ExtrudeName");




Message 2 of 6
in reply to: loster.mcleod

Here's a simple script that demonstrates changing the profile used for an extrusion.  The main thing to remember is that you're still under all the constraints as when you edit the profile in the user-interface.  Primarily that the sketch the profile is from must exist in the timeline before the extrude.


To edit the extrusion to point to a different profile, you have to roll the timeline back to before the extrusion.  This happens automatically in the UI when you edit a feature.  In the API you have to explicitly do it.  It's demonstrated in the script.

def run(context):
        app = adsk.core.Application.get()
        ui = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        msgResult = ui.messageBox('Yes = Create\nNo = Edit', 'Create or Edit', 
        if msgResult == adsk.core.DialogResults.DialogYes:
            sk = root.sketches.add(root.xYConstructionPlane)
            circles = sk.sketchCurves.sketchCircles
            circles.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 2)
            circles.addByCenterRadius(adsk.core.Point3D.create(5,0,0), 1)

            prof = sk.profiles.item(0)
            extrude = root.features.extrudeFeatures.addSimple(prof, 
   = 'Test Extrude'
            extrude = root.features.extrudeFeatures.itemByName('Test Extrude')

            sk = extrude.profile.parentSketch
            prof = sk.profiles.item(1)

            tl = des.timeline
            currentPstn = tl.markerPosition
            extrude.profile = prof
            tl.markerPosition = currentPstn
        if ui:
Brian Ekins
Inventor and Fusion 360 API Expert
Message 3 of 6
in reply to: BrianEkins

Wow! Thank you so much, I will try this!!


Message 4 of 6

Unfortunately, it doesn't seem to work.


I do this now, but the profile is still not selected and the extrude feature is in yellow (warning) in the timeline.

Sketch1 is created before the extrude feature. Sketch1->profiles()->count() is 1.



Message 5 of 6

Maybe this is related to the CPP API?? I was missing core.lib and some other libs that I had to download from a package on here.. They date from april 19th. Could that be the problem? If so, where are those new libraries?


I reinstalled fusion and now have the most recent libraries, but still not working.

Message 6 of 6

I have a work-around, but it seems there's an issue in the api.

I created a second sketch and make a profile in the new one. After that, I never have issues to change the profile of the extrude.


So I have sketch1, create the extrude. I now run my add-in again, create sketch2 instead and bind the profile to the extrude. I then rerun the add-in, recreate sketch2 with the same name, and no problem.


So it looks like I have to never delete anything in the sketch and simply rollback the timeline and recreate the sketch.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report