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.
Squaring Variable expression or how to square a number in onshape

been stuck on this for ages - I cant seem to get this variable expression to work and despite asking LLMs for help on the topic they also seem to be unsure as to why it doesnt work - i have tried making them unitless too but the expression just doenst seem to work. any help appreciated
full expression is:
sqrt((#upper_x**2) + (#upper_y**2))
but no matter how i seem to try ad write the experession i get a syntax error
edit: changed title for better search results
Comments
It's because the values have units, so you are creating mm^2
Try: sqrt((#upper_x/mm)^2 + (#upper_y/mm)^2) * mm
hmm, actually Neil, the sqrt cancels out the square returning the units to the proper mm.
but the "**2" syntax is wrong. for square, use "^2"
@jelte_steur814 is correct — sqrt(#upper_x^2 + #upper_y^2) should work with units. Even better is hypot(#upper_x, #upper_y).
thanks both for the answers - i did soon find this out after the post and was able to get the correct output
the ai overview response suggested the use of "**" to square numbers - hopefully the above will provide a quick search result for others
I would recommend trying out Onshape's own AI Advisor, which should not provide misleading information the way a "generic" google search does…
https://learn.onshape.com/pages/ai-advisor
Side note, this should be way easier to find!