User parameters null after one variable is set?

Anonymous

User parameters null after one variable is set?

Anonymous
Not applicable

I send a set of data to Fusion through a web app. My add in then parses the data and gets an array of user parameter names and the values that they are to be set to. I then run a loop where each user parameter is accessed through the itemByName method and the expression is set to the value that I send.

 

This works fine for the first variable, but the second time through the loop no variable name can be found. If I alter the order in which the parameter names are sent, the effect is still the same. It is as if the userParameters are reset after an expression is set?

 

 

# With the design open, alter all of the sent parameters
design = app.activeProduct
for n in range(len(eqNames)):
    thisParam = design.userParameters.itemByName(eqNames[n])
    if thisParam is None:
        print('Null variable - '+eqNames[n])
    else:
        thisParam.expression = eqValues[n]

 

 

The first time through the loop, the user parameter is set appropriately. Every time thereafter, I get a null/None.

0 Likes
Reply
296 Views
1 Reply
Reply (1)

Anonymous
Not applicable

I was eventually able to get this to work. It was a combination of whitespace at the start of the variable names and the use of adsk.fusion.Design.cast(app.activeProduct) vs app.activeProduct

0 Likes