parameterIO question

parameterIO question

Anonymous
Not applicable
408 Views
1 Reply
Message 1 of 2

parameterIO question

Anonymous
Not applicable

Hello - very new to Fusion 360 and not really a programmer but here is what I am trying to do. I am looking at using Fusion360 to "build" kitchen cabinets. I want to draw the cabinet with all parts and export the part names and dimensions. I have played a little bit with the Parameter IO  add-in in the apps. By renaming parameters, I can get most of what I want in a the CSV file. Is there a way to have it export the Value of the parameter instead of the Expression? I looked at the Pyton code and it looks like this is defined by line 217 to 218 or so. I see

 for _param in design.allParameters:
        result = result + _param.name +  "," + _param.unit +  "," + _param.expression + "," + _param.comment + "\n"

Would this be the place to modify the file to have it output the Value field? If so how would it need to be modified and once modified, how would I test the result in Fusion360? Is there a better way to do this or another program pout there that will generate a BOM in csv format?

 

Thanks,

Dan Cation

0 Likes
409 Views
1 Reply
Reply (1)
Message 2 of 2

liujac
Alumni
Alumni

The value property on Parameter object returns the value in database units. You can use UnitsManager.convert method to convert the value from one unit to another. Please try the code below:

 

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)
        
        unitsMgr = design.unitsManager
        result = ''
        for _param  in design.allParameters:
            valueInDatabaseUnit = _param.value
            valueInCurrentUnit = unitsMgr.convert(valueInDatabaseUnit, unitsMgr.internalUnits, _param.unit)
            result = result + _param.name +  "," + _param.unit +  "," + _param.expression + "," + str(valueInDatabaseUnit) + "," + str(valueInCurrentUnit) + "," + _param.comment + "\n"
        ui.messageBox(result)

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

You can check the values on “Parameters” dialog (“MODIFY”-“Change Parameters”) on UI, the values should be same.

To understand units in Fusion, you can read http://help.autodesk.com/view/NINVFUS/ENU/?guid=GUID-A81B295F-984A-4039-B1CF-B449BEE893D7.

 

Jack

0 Likes