Error Adding User Parameter Using Python

Error Adding User Parameter Using Python

garyTAC3Y
Participant Participant
1,250 Views
2 Replies
Message 1 of 3

Error Adding User Parameter Using Python

garyTAC3Y
Participant
Participant

Hello All,

 

I was successful with pulling all of my userParameters from a design, converting them to JSON, then saving them to a file. Now that I have switched to a new design, I am trying to read that saved file, convert back from JSON to a nested dictionary, and then create userParameters using the info in that nested dictionary.

 

Everything works great up to the point where I try to create (ADD) a new userParameter. No matter what I use for parameters in the app.activeProduct.userParameters.add, I get...

 

TypeError: in method 'UserParameters_add', argument 3 of type 'adsk::core::Ptr< adsk::core::ValueInput > const &'

 

from...

        design = app.activeProduct
        userp=design.userParameters
        result = userp.add('testing',123,'in','this is a test')

This is a static example of course. I reverted to this after the elements from my dictionary were throwing the same error.

Thanks!

 

 

0 Likes
Accepted solutions (1)
1,251 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @garyTAC3Y -San.

 

The second argument must be a ValueInput object.

        userp: adsk.fusion.UserParameters = design.userParameters
        result = userp.add(
            'testing',
            adsk.core.ValueInput.createByReal(123),
            'in',
            'this is a test'
        )
Message 3 of 3

garyTAC3Y
Participant
Participant
Thank you for the info! I see that I somehow missed the object type required and now I have read up on it. I sincerely appreciate the help!