How do you set User Parameter units to radians from a Script?

How do you set User Parameter units to radians from a Script?

Anonymous
Not applicable
858 Views
2 Replies
Message 1 of 3

How do you set User Parameter units to radians from a Script?

Anonymous
Not applicable

Hi,

I am writing a Python script to populate the UI User Parameter table from within the script - code snippet attached.

I have been able to set the length units (cm) and no units options within the User Parameter table without issues (as indicated in the attached screen grab).  I cannot find an API method that sets the angular units in the 'units' drop-down menu. My code is using Radial (R theta) values for vectors. There is a 'defaultLengthUnits' option that provides units for length values, but there is no similar method for setting the 'defaultAngleUnits' .... hope this makes sense...

To prove the code I have used the '' separator to set the angle field to no units, which has validated that the User Parameter table is being populated with the correct Text and values. 

The question is what is the method that will produce the required default angular units selection in the Parameter table?

Thanking you in advance - Paul

 

### Parameter Table Population Code snippet ####

 

#create user parameters
cm = design.unitsManager.defaultLengthUnits
createParam(design, 'radius', '5cm', cm, '')
createParam(design, 'Cone_Dist', '6cm', cm, '')
createParam(design, 'Cone_Angle', '0.25', '', '')

 

### Parameter Table Results ###


Parameters.JPG

 

 

 

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

BrianEkins
Mentor
Mentor
Accepted solution

You just need to use the string "rad" as the unit type.  Here's an example.

userParams = des.userParameters
param = userParams.add('TestAngle', adsk.core.ValueInput.createByReal(3.14), 'rad', 'test')
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

Anonymous
Not applicable

Brian,

Thanks for the speedy reply  - works a treat. Noted that you can use this to change to any of the User Parameter units listed in the units drop-down...... ft, yds, micron etc.

Thanks and regards

Paul

 

 

0 Likes