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.
Expressions - Returning a number when using a length

Hi I'm having a bit of trouble generating an integer for a pattern number from an expression which is using an length (mm).
floor((#length/2)/60)
I'm assuming the issue is incompatible types but not sure how to solve it. Is there any way to cast #length as an int?
floor((#length/2)/60)
I'm assuming the issue is incompatible types but not sure how to solve it. Is there any way to cast #length as an int?
0
Comments
I didn't test this, but something like this should work:
floor((#length/2)/60)/(1 mm)
If you ever change the units of the document it's going to break, and I can't quickly think of a way to make this so that it will just get rid of the units in a universal way.
https://forum.onshape.com/discussion/18076/new-feature-linear-pattern-plus/p1
floor(#length/2/60/(1mm))
Independent Onshape Consultant
Can someone please explain this nonsense? dividing length by a number = length, dividing length by a length = number? WTF?
Think of units as something that can be divided out.
mm/mm = 1
andin/mm = 25.4
Since
#length
has units in it already, to get a number for the floor function, you have to divide by units. So if#length = 5mm
you could get just 5 with#length/mm = 5
Independent Onshape Consultant
How do you divide a meter in half?
1m / 2
, which is a length. How many50cm
lengths are in a meter?1m / (50cm)
, which is a number.That is actually a brilliant explanation. Thank you!