Renaming parameter

Renaming parameter

hawx75
Participant Participant
501 Views
0 Replies
Message 1 of 1

Renaming parameter

hawx75
Participant
Participant

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 Likes
502 Views
0 Replies
Replies (0)