Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

How can I delete a parameter?

marcosscriven
Enthusiast Enthusiast
1,916 Views
5 Replies
Message 1 of 6

How can I delete a parameter?

marcosscriven
Enthusiast
Enthusiast

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. 

0 Likes
Accepted solutions (1)
1,917 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

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

 

UserParameter::deleteMe

1 Like
Message 3 of 6

marcosscriven
Enthusiast
Enthusiast

Thanks so much - that worked.

0 Likes
Message 4 of 6

davidpbest
Advocate
Advocate

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.

0 Likes
Message 5 of 6

kandennti
Mentor
Mentor

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.

2 Likes
Message 6 of 6

davidpbest
Advocate
Advocate

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

0 Likes