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.

Issue with variables not being available in sketches

jean_marc_billaudjean_marc_billaud Member Posts: 11

Hello,

I am happily progressing in using Onshape.

I want to use variables. From what I have seen, a variable I create can be used in the sketches that I will create AFTER creating the variable. But I cannot refer to it in a sketch that already existed at the moment when I created the variable. By the way, the variable disappears from the variable table as soon as I open an "old" sketch for editing.

In a previously existing sketch, I can create a variable with the same name as this particular variable I want to use, with whatever value. However, if I do that, the Part Studio related variable seems frozen : its value can no longer be modified.

Is this the normal behaviour ? Is there a way to define a Part Studio related variable that will be usable in any sketch, whatever the creation chronology ?

Comments

  • eric_pestyeric_pesty Member Posts: 2,073 PRO

    Move the variable up in the tree above the sketch you want to use it in

  • glen_dewsburyglen_dewsbury Member Posts: 944 ✭✭✭✭

    You can initiate a variable during the sketch/feature. When the value dialog opens during dimensioning enter # instead of a number and a list will show up. Select new variable and the variable dialog opens. When that is complete the variable will show up in feature tree ahead of sketch/feature. As Eric says, move up the tree to make available in previous features/sketches.

  • jean_marc_billaudjean_marc_billaud Member Posts: 11

    Thanks.

    I do not yet understand the full power of the tree. But I am one step closer today.

  • rick_randallrick_randall Member Posts: 386 ✭✭✭
    edited February 1

    @jean_marc_billaud - What I do is create a folder at the top of the feature tree, that I named "variables". This is where I keep all variables, and they will always be available in any sketch. I started doing this before OnShape introduced the variable tables, and it just became a habit - right or wrong, it works for me. Just thought I would share.

    Also makes it very easy to show/hide the variable list.

  • eric_pestyeric_pesty Member Posts: 2,073 PRO

    @rick_randall ,
    Putting the variables at the top does work, but there is a potential performance impact…
    On a simple part studio it doesn't matter but if you have some "heavy" features (i.e. long regen times) early in the tree they will have to be re-computed every time you change any of the variables so if that is the case it's better to have any variables that aren't needed for these slow features further down to avoid needlessly re-computing them.

    Not a big deal in most cases but something to be aware off…

    @jean_marc_billaud ,
    Think of the tree as a "step by step" guide to building your part(s) that are followed starting from the top. The order you perform the steps matters (for most steps anyway!). So in this case if you add a variable, it doesn't exist for any of the features before it.

  • rick_randallrick_randall Member Posts: 386 ✭✭✭

    @eric_pesty - Thanks for the heads-up, most of my work is simple hobby related stuff, and hasn't been an issue for me - but I can see where this might be an issue for some pro users. I will be mindful in the future, good to know.

Sign In or Register to comment.