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.

Is it possible to have driven variables?

carl_malagodicarl_malagodi Member Posts: 18 EDU
edited July 2022 in Community Support
Is it possible to have a variable that is only driven by a dimension, for example in the polygon sketch entity it doesnt appear to be possible to make the number of sides driven by a variable, is there a way to make a variable be driven by the number of sides instead? This isn't a use case I'm considering, more of a way to try to communicate what I'm trying to find out.

Best Answers

  • S1monS1mon Member Posts: 2,901 PRO
    Answer ✓
    It seems like you are correct about the polygon sketch entity. Interestingly, sketch pattern counts can be set with a variable. Both are show as "5x", so it seems like someone just assumed that driving the polygon tool with a variable wasn't as common, and didn't get to it. If it was an important use case to you (and it sounds like it isn't), then I would file an improvement request.

    Similarly, I don't know an easy way to extract the count of either polygon sides or sketch patterns without using some FeatureScript to create the entities in the first place.

    You can extract general measurements (including areas and perimeters) into variables, which can be very useful. Look at Measure value. There's also a "sensor" FeatureScript for clearances and other measurements, which can generate warnings if something is out of a predefined range.


  • eric_pestyeric_pesty Member Posts: 1,836 PRO
    Answer ✓
    Note that you could use a "measure" feature on the angle between the first two sides and do the math to get the number of sides in a variable for use in a downstream feature...

    But if you can't drive the number of sides it might not be that useful...

    Depending what you are trying to do you might be able to achieve what you want with a circular feature pattern instead of the polygon tool...
  • eric_pestyeric_pesty Member Posts: 1,836 PRO
    Answer ✓
    I missed the end of your statement.
     As a general rule you should be able to make a driven variable out of pretty much anything using the measure custom feature.
    The only limitation is that you have to create it after what is driving it.
    For example there is no way to have a driven variable within a sketch that you can also use in the same sketch.

Answers

  • S1monS1mon Member Posts: 2,901 PRO
    Answer ✓
    It seems like you are correct about the polygon sketch entity. Interestingly, sketch pattern counts can be set with a variable. Both are show as "5x", so it seems like someone just assumed that driving the polygon tool with a variable wasn't as common, and didn't get to it. If it was an important use case to you (and it sounds like it isn't), then I would file an improvement request.

    Similarly, I don't know an easy way to extract the count of either polygon sides or sketch patterns without using some FeatureScript to create the entities in the first place.

    You can extract general measurements (including areas and perimeters) into variables, which can be very useful. Look at Measure value. There's also a "sensor" FeatureScript for clearances and other measurements, which can generate warnings if something is out of a predefined range.


  • eric_pestyeric_pesty Member Posts: 1,836 PRO
    Answer ✓
    Note that you could use a "measure" feature on the angle between the first two sides and do the math to get the number of sides in a variable for use in a downstream feature...

    But if you can't drive the number of sides it might not be that useful...

    Depending what you are trying to do you might be able to achieve what you want with a circular feature pattern instead of the polygon tool...
  • eric_pestyeric_pesty Member Posts: 1,836 PRO
    Answer ✓
    I missed the end of your statement.
     As a general rule you should be able to make a driven variable out of pretty much anything using the measure custom feature.
    The only limitation is that you have to create it after what is driving it.
    For example there is no way to have a driven variable within a sketch that you can also use in the same sketch.
  • EvanReeseEvanReese Member, Mentor Posts: 2,081 ✭✭✭✭✭
    Sketch polygons are a special case. It's not that it was overlooked, but that it was considered and not implemented for some reason that I still don't totally understand, and wish someone would make it work. My workaround is to make a wedge of the polygon as a surface, and pattern that with a variable. I like the spirit of this question though (still wanting one place to make the edit). I hadn't thought to try it that way, but the measure value feature does have a "count" setting that finds identical entities, so it works for this case like this. https://cad.onshape.com/documents/739035f19f8cf89e6336aa07/w/64534bbc9bb3a6c9da98ff9b/e/ed7dff9e3257ebc2dea9af5d
    Evan Reese
  • carl_malagodicarl_malagodi Member Posts: 18 EDU
    From what I was reading on a forum post I think a possible reason for not implementing the variables for sketch polygons was as to not allow the user to change the number of vertices in a sketch in something like a configuration, however that's just a theory, could be for some reason entirely, also the measure value tool works well, thanks.
Sign In or Register to comment.