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.

Configurations & if Statements

Nath_McCNath_McC Member Posts: 114 PRO
Hi,

I am coming from Solidworks and i would have normally put a simple if statement in the dimensions to get the desired result but that is not the case in onshape.

I have a model of a pin and a hole. Currently the pin has a variable of #PinD and basically I want to incorporate the following if statement for the hole

If ( #PinD * 1.2 > #PinD + 3 , #PinD * 1.2, #PinD + 3 )

Basically the hole to be which ever size is grated,  #PinD * 1.2 or #PinD + 3

What is the best way to add this into the model?

Best Answers

  • Nath_McCNath_McC Member Posts: 114 PRO
    Answer ✓
    Brilliant, it was the brackets and units that I missing out. 
  • RyanWiebeRyanWiebe Member Posts: 8 ✭✭
    Answer ✓
    TimRice said:
    Our numeric inputs are actually quite flexible. This is possible using a ternary operator, as seen in the example below:


    This applies to any numeric input in our product (both part studios and assemblies).
    Is it possible for the value to read: ((#check>2*in) ? 3 : #check) in ?
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,308
    Answer ✓
    @r_w448 #check already has units so that would result in #check*in which is in^2 which is an area not a length. 

    Try (#check>2*in)?3*in:#check
    Senior Director, Technical Services, EMEAI

Answers

  • Nath_McCNath_McC Member Posts: 114 PRO
    Answer ✓
    Brilliant, it was the brackets and units that I missing out. 
  • RyanWiebeRyanWiebe Member Posts: 8 ✭✭
    Answer ✓
    TimRice said:
    Our numeric inputs are actually quite flexible. This is possible using a ternary operator, as seen in the example below:


    This applies to any numeric input in our product (both part studios and assemblies).
    Is it possible for the value to read: ((#check>2*in) ? 3 : #check) in ?
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,308
    Answer ✓
    @r_w448 #check already has units so that would result in #check*in which is in^2 which is an area not a length. 

    Try (#check>2*in)?3*in:#check
    Senior Director, Technical Services, EMEAI
  • RyanWiebeRyanWiebe Member Posts: 8 ✭✭
    @NeilCooke thanks! That cleared it up for me. I was trying to follow the example in the attached picture but I wasn’t being successful.
  • wout_theelen541wout_theelen541 Member, csevp Posts: 198 PRO
    It would be great if these statements were outlined in a course in the learning center.
  • wout_theelen541wout_theelen541 Member, csevp Posts: 198 PRO
    It would also be handy if you could control suppression with logic. The easiest example is I have a beam and if it is longer than X it needs an extra support.
Sign In or Register to comment.