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: 

Parameters dialog box: reference names for columns/levels displayed (Python)?

2 REPLIES 2
Reply
Message 1 of 3
atherisinnovations
582 Views, 2 Replies

Parameters dialog box: reference names for columns/levels displayed (Python)?

Hi,

What is this level of the model parameters dialog called? I mean what is its proper API reference (python)? Is it referenced as a feature or is it something else? In the timeline it is a name, but in the modelParameters list it is something else (modelParam.name returns a d-number, not the feature as it is named onscreen).
ModelParameters1.png

 Does hierarchy go something like this?:

Model Parameters>>Component>>(Feature?)>> (FeatureRole?)>ParameterName>ParameterUnit>ParameterExpression ??

 

Thanks!

2 REPLIES 2
Message 2 of 3

I've also done some exploring and edited the DumpParameters script written by Brian Ekins, but I still can't output the on-screen names of the 'feature' level of the Parameter Dialog window. Here's the script as I have re-worked it:

#Author-Brian Ekins
#Altered by Stephen Brzykcy
#Description-Dumps out parameter info to a specified csv file.

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        # Get the name of the file to write to.
        fileDialog = ui.createFileDialog()
        fileDialog.isMultiSelectEnabled = False
        fileDialog.title = "Specify result filename"
        fileDialog.filter = 'CSV files (*.csv)'
        fileDialog.filterIndex = 0
        dialogResult = fileDialog.showSave()
        if dialogResult == adsk.core.DialogResults.DialogOK:
            filename = fileDialog.filename
        else:
            return

        des = app.activeProduct

        result = 'Component,Type,CreatedBy,Role,Expression,Unit,cmORrad,ParamName\n'
        

        # Get the data for all user parameters.
        for userParam in des.userParameters:
            result += ('UserComp,User,NA,' + userParam.comment + ',' + userParam.expression + 
                           ',' + userParam.unit + ',' + str(userParam.value) + ',' + userParam.name + '\n')


                           
        for comp in des.allComponents:
            for modelParam in comp.modelParameters:
                result += (comp.name + ',Model,' + str(modelParam.createdBy) + ',' + modelParam.role + ',' + modelParam.expression + 
                           ',' + modelParam.unit + ',' + str(modelParam.value) + ',' + modelParam.name + '\n')                   

        output = open(filename, 'w')
        output.writelines(result)
        output.close()
        
        ui.messageBox('File written to "' + filename + '"')

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

 

Here is a snippet of the csv output:Screen Shot 2018-05-02 at 10.58.54 AM.png

 

 

 

This does ok. I would still like to have the on-screen names of the features referenced by their dimensions, not just the component. Can anyone help?

 Thanks!

-Stephen

Message 3 of 3

Hello,

 

In most cases, you can get reference names by following codes if the parameters belong to objects represented in Timeline. If not, you may have to cast "CreatedBy" property of parameter to concrete objects and get names of those objects.

 

Thanks,

Marshal

 

import adsk.core, adsk.fusion, traceback


def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent
        
        modelparams = root.modelParameters
        for modelparam in modelparams:
            ui.messageBox('name: {}, role: {}, createBy: {}'.format(modelparam.name, modelparam.role, modelparam.createdBy.timelineObject.name))

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


Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report