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.

How to define a range dependent variable?

adi_noyboer004adi_noyboer004 Member Posts: 3 PRO

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

  • _anton_anton Member, Onshape Employees Posts: 538 image

    <=, not =<

  • adi_noyboer004adi_noyboer004 Member Posts: 3 PRO

    I tried it as well, same resaults

  • eric_pestyeric_pesty Member, pcbaevp Posts: 2,673 PRO

    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)

  • S1monS1mon Member Posts: 4,151 PRO

    @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

  • adi_noyboer004adi_noyboer004 Member Posts: 3 PRO

    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)

  • EvanReeseEvanReese Member, Mentor Posts: 2,890 PRO
    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.