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.
Refer to Variables in Another Part Studio?
john_wolter
Member Posts: 14 EDU
Best Answers
-
lougallo Member, Moderator, Onshape Employees, Developers, csevp Posts: 2,005Not yet but planned yes.Lou Gallo / PD/UX - Support - Community / Onshape, Inc.6
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215This is already possible for FS -- setVariable and getVariable associate FS values with a context, so a feature can read variables that an earlier feature has set.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5
Answers
Example: I would like to create variables in one FS and call them in another FS
Wouldn't it be fairly simple to add it as a "Configurable" variable capability: so add to the existing: List, Checkbox, Configuration variable
>Referenced Variable?
>>with context references
Just noting that its 4yrs since OS employees last commented on this: any chance of a fairly rapid implementation of this as seems like you guys have it fairly sorted as to what's require?
This could be vital functionality in step toward "Conditional Configurations"
using variables from other docs is possible, but ofcourse true 'global variables' are not here yet. There are a number of work arounds in the mean time i'd help set you up if you want.
one way is to create a featurescript
The only code you need for each variable is:
setVariable("context","varName",value);
If you want a variable that is driven from the context of another doc, you can create a sketch and draw a line to represent the value as a length. Set it's length with a dim using your variable.
Import that sketch into your new doc. Now you can use the measurevalue featurescript to set the length of the line back to a variable if you like.
You can also use a CSV file to create variables on the fly, I have a featurescript for that if you want too. No coding needed
P.S. don't bother asking when, they can't tell you even if it's tomorrow and they really want to
We are still planning to do true global variables -- I can say they've definitely bubbled up in priority since four years ago, but that's as much as I can say on "when".
With respect to making Design Variables accessible to other part studios and across documents, why not make "Design Variable" features something that can be referenced via the Derived feature?
From a UI and conceptual usage standpoint this seems like an obvious approach.
Currently one can reference Parts, Planes and Sketch features from a Part Studio, so why not a Design Variable?
A nice touch would be add a checkbox(es) to Design Variable creation UI to either limit the scope to Part Studio, or document it is defined in, and/or make it accessible to other documents.
Just a thought.
edit: I skimmed the thread and missed this had already been posted. I love this feature though.
From what I can tell, the feature script allows one to reference (derive) parts, sketches, planes from a different Part Studio (current doc or another) and place them in arbitrary locations using existing or dynamic mate connectors. Plus you get the option to preform a boolean of the derived parts against existing parts in the Part Studio.
Maybe a more accurate name for the feature script would be: SuperDeriveW/TransformByMateConnectorPlusOptionalBoolean"
Obvious work in progress:
https://forum.onshape.com/discussion/18569/improvements-to-onshape-june-27th-2022/p1