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.
Global Variables?
sloan_thrasher
Member Posts: 3 ✭✭
Looks like a lot of people are asking for global (at least within a document) variables.
Are there any plans to add this feature?
5
Best Answers
-
romeograham Member, csevp Posts: 678 PROI imagine you've already added your vote to the Improvement Request here: https://forum.onshape.com/discussion/4027/global-variables#latest
If you haven't please do!
That's the main way that Onshape knows what features we want (and any improvement requests you submit through your "Contact Support" link in-document).
Romeo5 -
rune_thorsen229 Member Posts: 182 EDU@sloan_thrasher
Its strange this hasn't been solved despite numerous calls and the obvious necessity. https://forum.onshape.com/discussion/comment/60779#Comment_60779
However so far I do it by a featurescript:
1. next to the tabs press plus - 'create feature studio'
2, insert the code below where "thickness" etc. will be your global values
3. press [commit]
4. on each part studio - SIGH - (where you want to use the globals) you press the {[]} symbol 'Custom features...' and insert '"Global Dimensions"' (name defined in the featurescript below). Put it early in your features list.
5 Now you have these centrally defined variables at your disposal.
e.g. : #thickness, #connhole etc.
----------START ------FeatureScript 1024;import(path : "onshape/std/geometry.fs", version : "1024.0");const VALUES = { // Below we have the global variables driving the design:"thickness" : 1.5 * millimeter, //Thickness of walls"connhole" : 1.2 * millimeter, //Connector hole"bandwidth" : 20 * millimeter, //The width of the wrist band"padding" : 5 * millimeter, //Padding from skin to band"margin" : 0.5 *millimeter , //Distance between objects"gap" : 0.8 *millimeter //Distance between objects};annotation { "Feature Type Name" : "Global Dimensions" }export const setGlobals = defineFeature(function(context is Context, id is Id, definition is map)precondition{}{for (var value in VALUES)setVariable(context, value.key, value.value);});
---------END ---------2 -
Jonatan_Schumacher Member Posts: 2 ✭You can now use the new "Variable Studio" to define shared variables: https://cad.onshape.com/help/Content/variable_studio.htm1
Answers
If you haven't please do!
That's the main way that Onshape knows what features we want (and any improvement requests you submit through your "Contact Support" link in-document).
Romeo
Its strange this hasn't been solved despite numerous calls and the obvious necessity. https://forum.onshape.com/discussion/comment/60779#Comment_60779
However so far I do it by a featurescript:
1. next to the tabs press plus - 'create feature studio'
2, insert the code below where "thickness" etc. will be your global values
3. press [commit]
4. on each part studio - SIGH - (where you want to use the globals) you press the {[]} symbol 'Custom features...' and insert '"Global Dimensions"' (name defined in the featurescript below). Put it early in your features list.
5 Now you have these centrally defined variables at your disposal.
e.g. : #thickness, #connhole etc.
----------START ------
---------END ---------