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.

Variable

D_7D_7 Member Posts: 6 PRO
Assign Variable for the entire PartStudios in the Document...
Tagged:

Comments

  • owen_sparksowen_sparks Member, Developers Posts: 2,264 PRO
    Please see this IR:
    Cheers, Owen S.
    Production Engineer
    HWM-Water Ltd
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,285
    @D_7

    A good workaround for now is to write a custom feature which sets all the variables, and then call that custom feature at the beginning of each part studio:
    https://cad.onshape.com/documents/4bcc69a118838dd41e979713/w/19539881356ff2f22ff15dd8/e/5fca1275e609277a3b90e253




    Jake Rosenfeld - Modeling Team
  • D_7D_7 Member Posts: 6 PRO
    @Jake_Rosenfeld Can I Use It For Entire Document ???
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,175
    @D_7 yes, just use the custom feature as the first feature in each part studio in your document
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • john_mcclaryjohn_mcclary Member, Developers Posts: 1,851 PRO
    Not in assemblies though.
  • owen_sparksowen_sparks Member, Developers Posts: 2,264 PRO
    D_7 said:
    @Jake_Rosenfeld Can I Use It For Entire Document ???

    NeilCooke said:
    @D_7 yes, just use the custom feature as the first feature in each part studio in your document
    Actually it's better than that.  If you want some really-really-global variables you can use it in multiple documents, for anyone you care to share the featurescript with, so you could in theory use them across the planet.  (Though you'd need to revision the FS source doc and then update the FS in the target PS if you change the variable value and that would update anything that used the feature.)
    Owen S.
    Production Engineer
    HWM-Water Ltd
  • brian_bradybrian_brady Member, Developers Posts: 395 EDU
    @D_7

    A good workaround ...
    Sorry, but no such thing as a "good workaround." If it was "good" it would be the correct approach, not the "workaround." Onshape really, really, really needs to separate variables from the feature tree. That way they always exist as if they were created before anything else. The only precedence needed is the order of the variables. If variables existed outside of the feature tree, then they could be assigned to sketch dimensions on the fly as well.
  • john_mcclaryjohn_mcclary Member, Developers Posts: 1,851 PRO
    edited April 25
    @brian_brady
    Actually I think Onshape's approach is a better method:

    Because it is a feature, you can move it down your history tree, or add multiple featurescripts, and configure part studios by just suppressing/unsuppressing the global variable features.

    Because they are like any other variable. you can override each variable independently at the part studio level by defining a local variable with the same name, then having it below the global feature in the tree.

    I do this for sheet metal often, I'll have 2 variables (thickness & bendradius) then insert them before a sheet-metal feature, then I can quickly modify all the sheet-metal in a project by just removing an override, or dragging around the feature higher in the tree to influence more parts, or modifying the featurescripts.

    example:
    https://cad.onshape.com/documents/ad3a9824a02b9066da33b369/w/bb566cc2750ad4ccc29f90ce/e/41bd476940542832f1fcb98c
Sign In or Register to comment.