Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
EXPORTING VALUE
papawo
Member, Developers Posts: 206 PRO
Best Answers
-
konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭assign this to the global variable via setVariable() and all later added features then can obtain the value via getVariable()
5 -
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565FeatureScript has a few methods for sharing data between features:
- You can share them in variables (where the result is stored in the Part Studio context)
- You can set them as attributes (where the result is stored on specific geometric entities in the context)
- You can export a function which computes the result (this result is not stored, but is recalculated when needed)
I just made a public example document with a "setting" and a "getting" feature that outlines and uses each of these three methods:
https://cad.onshape.com/documents/b0ee3d7a54ed4f9d545aaf35/w/2ed81a2ae5a0b46f717613b5/e/2407302600fec1de0bf8fb1b
In every case, as with everything in FeatureScript, the data is computed as part of the regeneration of some Part Studio, and the data can change if that Part Studio changes.
Do you know which method is most useful for your application?
1
Answers
Can you describe what you mean by export?
- You can share them in variables (where the result is stored in the Part Studio context)
- You can set them as attributes (where the result is stored on specific geometric entities in the context)
- You can export a function which computes the result (this result is not stored, but is recalculated when needed)
Depending on your application, each method can be useful.I just made a public example document with a "setting" and a "getting" feature that outlines and uses each of these three methods:
https://cad.onshape.com/documents/b0ee3d7a54ed4f9d545aaf35/w/2ed81a2ae5a0b46f717613b5/e/2407302600fec1de0bf8fb1b
In every case, as with everything in FeatureScript, the data is computed as part of the regeneration of some Part Studio, and the data can change if that Part Studio changes.
Do you know which method is most useful for your application?
Thanks Kevin! Good explanation!