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: 

Sending parameters to Fusion - Arrays and value vs expression

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
joshuafoxworth
477 Views, 3 Replies

Sending parameters to Fusion - Arrays and value vs expression

I have a platform that sends data to Fusion 360 and an add on that parses the data to set the values of specific parameters to the values that are sent. I haven't really had a problem with this system so far.

 

My issue is that my platform defaults all values to standard metric - so meters instead of mm or inch. If the user has set the value of a user parameter to inches and I send a number then that will be interpreted as inches (at least that is my understanding). It seems to me that the best practice is for me to append the unit and send "3 m" and update the expression instead of the value. 

 

Is that the case?

 

Also, how can I handle a case where a user sends a vector or an array of data? 

 

Thanks

3 REPLIES 3
Message 2 of 4
BrianEkins
in reply to: joshuafoxworth

There are two properties on the Parameter object that let you set its value; expression and value.  The expression property is exactly equivalent to the "Expression" field in the Parameters dialog.  It is a string and is interpreted using the units assigned to that parameter.  For example, if the expression string is "5" and the units are inches then it will be interpreted as 5 inches but if the units are millimeters it will be interpreted as 5 mm.  Because it's a string it can also contain the units as part of the expression.  For example "5 in", which will always be interpreted as 5 inches regardless of the units assigned.  You can also have equations like "5/2" or "5 in/3 in" or "5 cm/2 in" or "Length/2", etc.

 

The second way of setting a parameter value is to use the value property.  The value property is a floating point, not a string.  This is an API only capability and is not provided through the user interface.  When using the value property the number always assumed to be in database units, which means for lengths the value is always centimeters and for angles, it is always radians.  Using the value property doesn't change the units of the parameter.  For example, if you have a parameter whose unit type is inches and you set the value property to 2.54, the parameter will still be in inches but its new expression will be "1".

 

As far as getting an array of numbers, I'm not sure what you're asking.  A parameter is a single value, not a list, so you'll need to choose which number from the array to use or possible use the array to set the value of multiple parameters.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4
joshuafoxworth
in reply to: BrianEkins

Appreciate the help. That's pretty much what I was thinking with the expression vs value.

 

As far as an array goes .... I was considering the case that a user on my end might want to send a vector of data to Fusion 360 that is then used as points for a curve or something similar.

Message 4 of 4
BrianEkins
in reply to: joshuafoxworth

You can certainly take a list of values and do anything you want with it using the API.  It could be a set of coordinates for a curve, or possibly a list of positions for parts in an assembly.  You're getting values, which might be individual values or grouped within a list, and then can use those values however you choose, including using them as input when using the Fusion API.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report