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 is this expression incorrect?

MannyFMannyF Member Posts: 12 ✭✭

I'm new to OnShape. I'm looking into formulas to drive a design and there are a couple of things I don't fully understand:

OnShape functions do not accept values with units, I assume this is so by design to keep things consistent, and the units must be supplied explicitly. Is there a list that defines the correct spellings? I use British English and was typing millimetre instead of millimeter and so the formula was being flagged as incorrect:

ceil(#WallThick * 3) ❌

ceil(#WallThick / mm * 3) * mm ✅

ceil(#WallThick / millimeter * 3) * millimeter ✅

Also learnt the hard way, units are case-sensitive (it would be nice if OnShape could automatically convert units to lower-case instead of generating an error without further explanation):

ceil(#WallThick / Millimeter * 3) * millimeter ✅

ceil(#WallThick / Millimeter * 3) * Millimeter ❌

Why is the first expression incorrect while he second is correct? For some reason the first instance of 1 mm needs to be enclosed in brackets, but the second does not:

ceil(#WallThick/ 1 mm * 3) * 1 mm ❌

ceil(#WallThick/ (1 mm) * 3) * 1 mm ✅

I'm sure I've just grown a few white hairs over this 😄

Best Answer

  • Matt_ShieldsMatt_Shields Member, Onshape Employees Posts: 630 PRO
    Answer ✓

    Sounds like you've basically got it. Always have to be careful about units. Can't add dissimilar units. And can't multiply length by a length and expect to get a length. Things like that.

    If #WallThick is in millimeters, you'll need to divide by mm to get it unitless, then perform a function like ceil() and then multiply again by mm. And yes, spelling and capitalization count 😀

    As for the last question, you need to divide #WallThick by 1mm in order to use ceil(). So, #WallThick/(1 mm) successfully does that. Your first expression basically says #WallThick / 1 * mm which will get you a unit in mm^2.

Answers

  • Matt_ShieldsMatt_Shields Member, Onshape Employees Posts: 630 PRO
    Answer ✓

    Sounds like you've basically got it. Always have to be careful about units. Can't add dissimilar units. And can't multiply length by a length and expect to get a length. Things like that.

    If #WallThick is in millimeters, you'll need to divide by mm to get it unitless, then perform a function like ceil() and then multiply again by mm. And yes, spelling and capitalization count 😀

    As for the last question, you need to divide #WallThick by 1mm in order to use ceil(). So, #WallThick/(1 mm) successfully does that. Your first expression basically says #WallThick / 1 * mm which will get you a unit in mm^2.

Sign In or Register to comment.