Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_wolterjohn_wolter Member Posts: 14 EDU
If I am in Part Studio 2, is there a way to refer to a variable in Part Studio 1?  If so, what is the syntax?  If not, is this planned?
Tagged:

Best Answers

Answers

  • Dylan_StewartDylan_Stewart Member, Developers Posts: 107 PRO
    @lougallo do you know if this is planned for FS as well? 

    Example: I would like to create variables in one FS and call them in another FS
    Digital Engineering
  • lundmikkellundmikkel Member Posts: 2 ✭✭
    @lougallo How far is this feature? Is it possible now? If not, will it be in the near future?
  • ParkwoodParkwood Member Posts: 4 PRO
    Any comment on how far from releasing the ability to reference a variable from another document is likely to be?

    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"
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,890 PRO
    edited August 2020
    @Jason_Clark

    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
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,173
    The super derive custom feature https://cad.onshape.com/documents/cfef86ed4f9635531599a973/v/5ee89fa6e9c437289bbc6f07/e/305f5ce7d2fdb46e12881f6f will let you bring in variables from another part studio.

    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".
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,890 PRO
    OH, nice. I didn't realize superderive did that
  • StephenGStephenG Member Posts: 367 ✭✭✭
    Just a thought...

    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.
  • Evan_ReeseEvan_Reese Member Posts: 2,060 PRO
    edited August 2020
    StephenG said:
    Just a thought...

    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.
    @ilya_baran is ahead of us on this with his Super Derive feature. https://cad.onshape.com/documents/cfef86ed4f9635531599a973/v/5ee89fa6e9c437289bbc6f07/e/305f5ce7d2fdb46e12881f6f?jumpToIndex=496&showReturnToWorkspaceLink=true

    edit: I skimmed the thread and missed this had already been posted. I love this feature though.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • StephenGStephenG Member Posts: 367 ✭✭✭
    I think the "SuperDerive" custom feature script is miss named; it should named "SuperTransform". 

    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:
    • No documentation yet.
    • Need a option to specify a "from" Mate Connector as the basis for positioning derived items. Currently, "From" is the global coordinate system.
    • "Include variables" option brings in all the design variables. Should be able to be selective as to which design variable(s) to derive. Imported variable names should be prefaced with SuperDerive feature name with a "." separator instead of arbitrary user prefix/suffix text.  
    • Should be able to use against the current Part Studio. (I like the ability to pattern a part in arbitrary locations, however this capability really should be supported under standard OS patterning using existing/dynamic mate connectors and/or sketch points in a sketch.) 


  • David_YL_NguyenDavid_YL_Nguyen Member, Onshape Employees Posts: 82
    Came across this older post and leaving a reference to VARIABLE STUDIOS (GLOBAL VARIABLES) here in case someone lands here while searching:
    https://forum.onshape.com/discussion/18569/improvements-to-onshape-june-27th-2022/p1
Sign In or Register to comment.