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.

Numeric Fields with Multiple Length Divisions and Additions

nicholas_aarestadnicholas_aarestad Member Posts: 14 EDU
Hello all, I've run into a bit of a roadblock using numeric fields with multiple configuration variables.

I am attempting to define a configuration variable's upper limit as a function of other configuration variables. Specifically, the (approximately) correct equation is:

(#X / 2) - (#Y / 2) - 1in

Where #X and #Y are both lengths. 

However, while I've tried a bunch of different ways of phrasing this, I can't seem to find one that Onshape will accept.

Specifically, I've tried:

(#X / 2) - (#Y / 2) - 1in
((#X / 2in) - (#Y / 2in) - 1)in
#X / 2 - #Y / 2 - 1

I've found a previous question which lead me to the reference manual's page on numeric fields (super interesting!) but all of its examples involving length are extremely basic.

Can anyone guide me in the right direction with this?

Thanks in advance!

Best Answer

Answers

  • chris_8chris_8 OS Professional Posts: 102 PRO
    I've gotten stuck on syntax too, so I know how you feel.  Variables are case sensitive, so make sure those are identical.  Spaces between the number and unit designation make a difference.  This worked for me:
    #X/2 - #Y/2 - 1 in

    example:
    https://cad.onshape.com/documents/097cd417dd0132907147b98d/w/829548ea8fccc921c00968ba/e/47a28d79fb61d6a117853a34

  • nicholas_aarestadnicholas_aarestad Member Posts: 14 EDU
    chris_8 said:
    I've gotten stuck on syntax too, so I know how you feel.  Variables are case sensitive, so make sure those are identical.  Spaces between the number and unit designation make a difference.  This worked for me:
    #X/2 - #Y/2 - 1 in

    example:
    https://cad.onshape.com/documents/097cd417dd0132907147b98d/w/829548ea8fccc921c00968ba/e/47a28d79fb61d6a117853a34

    Thanks for the suggestion! Unfortunately that syntax doesn't seem to work in my document. I'm wondering if it has to do with that I'm using Configuration Variables instead of Variables (from the toolbar), and if there's a restriction that I can't seem to find documentation for on not being able to use Variables or Configuration Variables to set the limits of another Configuration Variable (which I guess there would be some significant edge cases related to that).
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,210
    If #X and #Y are lengths, your first expression and @chris_8's equivalent expression is valid. It really shouldn't matter if there's a space between the number and the unit -- please file a bug if you find otherwise.
    The problem with the second expression, ((#X / 2in) - (#Y / 2in) - 1)in  is that #X / 2in is an area, not a number (as one might think) -- the unit here is multiplied, not divided -- e.g., 1/2 in is half an inch.  Doing (#X / (2 in) - #Y / (2 in) - 1) in will do what you intended.
    The problem with the third expression is you're subtracting a number (1) from a length #X / 2 - #Y / 2

    Hope this helps.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • nicholas_aarestadnicholas_aarestad Member Posts: 14 EDU
    edited May 2018
    Apologies for the double post, but I realized I didn't link any sort of demonstration document-- here's an example with three Configuration Variables set up, where I've tried setting #H's maximum and minimum as a function of the other two configuration variables.
  • nicholas_aarestadnicholas_aarestad Member Posts: 14 EDU
    If #X and #Y are lengths, your first expression and @chris_8's equivalent expression is valid. It really shouldn't matter if there's a space between the number and the unit -- please file a bug if you find otherwise.
    The problem with the second expression, ((#X / 2in) - (#Y / 2in) - 1)in  is that #X / 2in is an area, not a number (as one might think) -- the unit here is multiplied, not divided -- e.g., 1/2 in is half an inch.  Doing (#X / (2 in) - #Y / (2 in) - 1) in will do what you intended.
    The problem with the third expression is you're subtracting a number (1) from a length #X / 2 - #Y / 2

    Hope this helps.
    Thank you for the response! It makes sense that the last two wouldn't work-- honestly, I put them in there as an example of a couple of things that I had tried before I found the documentation.

    While I thought that this was originally a syntax thing, I can see now that the error message this gives me is "Enter a Number or Number with Units" which I suppose might imply that a function of other Configuration Variables or Variables is not a valid input, so it's probably more related to me not understanding the limitations on the feature.
Sign In or Register to comment.