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.

# List of Math Operations

Member Posts: 23 ✭✭
Is there a list of valid math expressions and operation such as cos( ), log( ), abs( ), etcetera?
Tagged:

• Moderator, Onshape Employees Posts: 5,541
Yes, please see the FeatureScript documentation under the help menu.
Senior Director, Technical Services, EMEAI
• Member, OS Professional, Mentor, User Group Leader Posts: 2,140 PRO
Engineer ı Product Designer ı Onshape Consulting Partner
Twitter: @onshapetricks  & @babart1977
• Member Posts: 23 ✭✭
Thanks abefeldman, I was a little surprised to not see a div operation but see now I can just nest a '/' inside a floor() to obtain an equivalent result.  Whereas div(a,b) or (a div b) = floor(a / b).
• Member, Developers Posts: 1,297 ✭✭✭✭✭
@michael_mcdonald047, be careful. I suspect A div B = floor(A/B) only when A/B is positive. Case in point, 5 div -2 = -2, but I believe floor(5/-2) = -3. If there was a SIGN function you could use sign(A/B)*floor(abs(A/B)). But as far as I can tell, there is no sign function. You could substitute sign(X)=X/abs(X).
• Member, Developers Posts: 1,297 ✭✭✭✭✭
Or you can use an inline "if".

AdivB = (A/B>= 0) ? floor(A/B) : ceil(A/B)
• Member Posts: 62 PRO
Hi, How do I square a config variable in a numeric field? (not a feature script)  I'm trying to get the hypotenuse length given #rise & #run for an array feature in a part studio. I would guess sqrt(#rise^2+#run^2) but that didn't work.  Realised I didn't know how to square a number! None of following worked: #run^2    #run*#run   #run.#run.

Had a quick look at the Feature Script documentation but not sure which part is relevant.

Found the following but can't see a square function anywhere.

https://www.onshape.com/en/resource-center/tech-tips/tech-tip-using-numeric-fields

• Member, csevp Posts: 669 PRO
You may also be running into a problem with units: your #rise variable includes mm as units. If you square that, you get mm*mm (which expresses an area, not a linear dimension). The part pattern is looking for a linear distance (only mm, not mm*mm).

You can divide by mm in your expression to cancel the units ((#rise/mm)*(#rise/mm)) which will give you a numerical value, that will get interpreted as a linear dimension (a "length") which is what the Pattern is looking for.

You could also change your Variables to be unitless - then this wouldn't be an issue.

Hope that helps!
• Onshape Employees, Developers, HDM Posts: 1,190
sqrt(#rise^2+#run^2) should work if #rise and #run are both lengths.  Please post a link to a version of your document where this expression isn't working and I or someone here will be able to tell you what's wrong.
Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc