How to define a range dependent variable?
Hello to you all,
I'm trying to define a variable (z) by a range of values for variable (k)
'k' range 'z' value
6<z=<8 1
8<z=<10 2
10<z 3
I was trying to define a variable by nesting expression { ((#k>6&&#k=<8)?1:(#k>8&&#k=<10)?2:3) }, but to no avail.
Please advise.
Sincerly
Answers
-
<=, not=<2 -
I tried it as well, same resaults
0 -
It gets a bit confused about the second part of the ternary, this should work if you add these brackets:
(#k>6&&#k<=8)?1:((#k>8&&#k<=10)?2:3)1 -
@EvanReese has a series of 6 videos on expressions and logic in Onshape. I highly recommend watching these since there are a number of useful tricks or things you might not have picked up from other sources.
https://www.youtube.com/watch?v=J7McsBIEeqc
Simon Gatrall | Product Development, Engineering, Design, Onshape | Ex- IDEO, PCH, Unagi, Carbon | LinkedIn
0 -
Well, the series Evan made helped me to debug the subject which is end up to be a syntax issue.
The nesting should be written like:
#k>6&&#k<=8?1:(#k>8&&#k<=10?2:3)
0 -




