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.

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

Chris_D_Mentes_001Chris_D_Mentes_001 Member, csevp Posts: 103 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_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    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_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    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_001Chris_D_Mentes_001 Member, csevp Posts: 103 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 }".

Sign In or Register to comment.