Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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
michael_mcdonald047
Member Posts: 23 ✭✭
Is there a list of valid math expressions and operation such as cos( ), log( ), abs( ), etcetera?
Tagged:
0
Best Answer
-
Also check out https://cad.onshape.com/help/#numeric-fields.htm and expand the "Accepted unit keywords" field.Abe Feldman
UX/PD/Community Support5
Answers
-
Yes, please see the FeatureScript documentation under the help menu.Senior Director, Technical Services, EMEA0
-
Also check out https://cad.onshape.com/help/#numeric-fields.htm and expand the "Accepted unit keywords" field.Abe Feldman
UX/PD/Community Support5 -
0
-
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).0
-
@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).0
-
Or you can use an inline "if".
AdivB = (A/B>= 0) ? floor(A/B) : ceil(A/B)0 -
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
1 -
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!0 -
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 Inc1 -
As of 3-Sept-2025 the following syntax works:
(sqrt(#rise^2 + #run^2) / mm) mm
0






