Message 1 of 1
Renaming parameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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()))