Why can't I pass a value with units to an opThicken

Chris_D_Mentes_001
Chris_D_Mentes_001 Member, csevp Posts: 132 PRO
Why can't I pass a value with units to an opThicken unless it's passed in as a variable from function parameter definition:
https://cad.onshape.com/documents/c8eef2271809c4293325c9b1/w/d82cceae829e190d1649e512/e/287a2ff37d6f3ee70d59456f (for onshape team only).
see line 61 to 69 and note that this all works with no errors if I replace "1e-6*meter" with "offset" both of which are valueWithUnits but behave differently:
    var th1 = offset<0?-1e-6*meter:0;
    var th2 = offset>0?1e-6*meter:0;
    println(th1 ~ " - " ~ th2);
    println(offset);
    opThicken(context, id + "TemporaryThickness", {
            "entities" : faces,
            "thickness1" : th1,
            "thickness2" : th2
    });
the above code gives error: @opThicken: INVALID_INPUT

Best Answer

  • caden_armstrong2
    caden_armstrong2 Member, User Group Leader Posts: 121 ✭✭✭
    Answer ✓
    A few things I notice:

    your th1 and th2 base case has no units. You need to replace 0 with 0*meter.
    You are comparing offset to a value without units.
    Additionally, you have a negative value for th1, both inputs for opThicken need to be positive.

Answers

  • caden_armstrong2
    caden_armstrong2 Member, User Group Leader Posts: 121 ✭✭✭
    Answer ✓
    A few things I notice:

    your th1 and th2 base case has no units. You need to replace 0 with 0*meter.
    You are comparing offset to a value without units.
    Additionally, you have a negative value for th1, both inputs for opThicken need to be positive.

  • Chris_D_Mentes_001
    Chris_D_Mentes_001 Member, csevp Posts: 132 PRO
    Ah! thats what got me. Thank you. I origonally had "-offset" in there temporarily cause it was quicker then writing a hard value. When I came back in I swapped it out for a hard value but forgot I wrote "-" because in that condition the "offset" variable was negative and needed to be made positive :tongue: . Also the reason my values where printing wierd is becasue they weren't printed individually. Apparently the "~" concatination turns a " 1.0 meter" into "ValueWithUnits : { "unit" : UnitSpec : { "meter" : 1 } , "value" : 1 }".