Configurations & if Statements

Nath_McC
Nath_McC Member Posts: 136 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_McC
    Nath_McC Member Posts: 136 PRO
    Answer ✓
    Brilliant, it was the brackets and units that I missing out. 
  • RyanWiebe
    RyanWiebe 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 ?
  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    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, EMEA

Answers

  • Nath_McC
    Nath_McC Member Posts: 136 PRO
    Answer ✓
    Brilliant, it was the brackets and units that I missing out. 
  • RyanWiebe
    RyanWiebe 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 ?
  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    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, EMEA
  • RyanWiebe
    RyanWiebe 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_theelen541
    wout_theelen541 Member, csevp Posts: 202 PRO
    It would be great if these statements were outlined in a course in the learning center.
  • wout_theelen541
    wout_theelen541 Member, csevp Posts: 202 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.
  • calvin_selin
    calvin_selin Member Posts: 11 EDU