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: 

User parameters Exosed in API?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
dirktheeng
2237 Views, 5 Replies

User parameters Exosed in API?

Are user parameters exposed through the API and/or will they be?  It would be nice to do this for creating models that are easy for the end user to modify.  The user parameters table is convenient to collect all important model parameters in one place and/or define relationships between parameters so they can be edited and redefined easily.

21st Century Woodworking

-Blending 21st Century Woodworking with Old World Skill
5 REPLIES 5
Message 2 of 6
ekinsb
in reply to: dirktheeng

As you already reported in the other topic, you can access user parameters using the Design object.  Model parameters can be accessed through the Component object.  Here's a small sample that demonstrates accessing specific parameters by name and changing their values.

 

import adsk.core, adsk.fusion, traceback

def main():
    ui = None
    try:
        app = adsk.core.Application.get()
        des = app.activeProduct
        
        # Get the model parameter named "Height".
        heightParam = des.rootComponent.modelParameters.itemByName('Height')

        # Increase the value 25%.
        heightParam.value = heightParam.value * 1.25
        
        # Get the user parameter named "Size".
        sizeParam = des.userParameters.itemByName('Size')
        
        # Set it using an expression.
        sizeParam.expression = "Height / 2"        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

main()

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 6
mhasan3
in reply to: ekinsb

if lets say, multiple components (occurances) are present in a document, is there any way to get access to the parameters of each occurance via the API?

Message 4 of 6

@mhasan3 

As you can see it is possible.

I achived it the following way:

- getting all user parameters

- traversing all components and store the ModelParameters for each

- searching the name of each UserParameter in the previously stored ModelParameters

- as result you get a list of all UserParameters for each component

 

fusion05.PNG

Message 5 of 6
cndA6U97
in reply to: ekinsb

How can we create new User parameters through the API ?  (Seems not to be documented in the API manual?)

Message 6 of 6
BrianEkins
in reply to: cndA6U97

You can use The userParameters object, which you get using the userParameters property on the Design object, supports an add method.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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