Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I delete a parameter?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
marcosscriven
1326 Views, 5 Replies

How can I delete a parameter?

I can add a parameter via the design.userParameters list - even though it claims to be read-only. 

However, the deleteByItem method results in a read-only error, and I see no way to get a mutable one. 

It seems the API is setup for adding and deleting user parameters, but deleting them doesn’t work as there’s no access to a mutable user parameter list. 

5 REPLIES 5
Message 2 of 6

You have to call the parameter's deleteMe() function.

 

UserParameter::deleteMe

Message 3 of 6

Thanks so much - that worked.

Message 4 of 6
davidpbest
in reply to: hobbyist.maker

OK, what is the phone number for the parameter's deleteMe() function..  Seriously, I have no idea what you're talking about.  Please elaborate on how to accomplish the "call parameter's deleteMe() function" operation.

Message 5 of 6
kandennti
in reply to: davidpbest

Hi @davidpbest -San.

 

User parameters can be obtained from the UserParameters property of the Design object.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-ba26f8cd-6136-44a8-81fe-b133198cfa2d 

We did a little testing.
I created two user parameters and used one in the extrusion.
1.png

 

Then we run this script.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface
        des: fusion.Design = app.activeProduct

        for name in ["length1", "length2"]:
            param = des.userParameters.itemByName(name)
            res = param.deleteMe()
            print(f"Were you able to delete '{name}'? : {res}")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Were you able to delete 'length1'? : True
Were you able to delete 'length2'? : False


The used user parameter could not be deleted by executing the deleteMe method.

Message 6 of 6
davidpbest
in reply to: marcosscriven

I have no interest in using some API or writing code/scripts.  But thanks for your suggestion

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