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: 

Renaming parameter

0 REPLIES 0
Reply
Message 1 of 1
hawx75
327 Views, 0 Replies

Renaming parameter

I'm trying to change the name of a parameter with the following code. I can change the expression but the name property doesn't change.

 

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
       
        # Access the import manager and root component
        importManager = app.importManager
        rootComp = app.activeProduct.rootComponent
        # Get the file to be imported, here we are telling it where the file is located
        filename = str("path to file")
        # Create the input options and import them to the target
        importOptions = importManager.createFusionArchiveImportOptions(filename)
        importManager.importToTarget(importOptions, rootComp)  
        
        # Get the occurence of the imported component
        rootComp = app.activeProduct.rootComponent
        importOccurenceCount = rootComp.occurrences.count        
        importOccurence = rootComp.occurrences.item(importOccurenceCount - 1) 

        # Get the list of all parameters
        parameters = importOccurence.component.parentDesign.allParameters            
        
        # Change parameter name and value
        param = parameters.itemByName('width')
        param.name = 'width_test'
        param.expression = '1000mm'       

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

 

0 REPLIES 0

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