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.
How do I change a the "length" variable to an "integer" variable in a different variable?
tiffany_jiang774
Member Posts: 2 EDU
What I'm trying to do is make a configurable tube with holes that go down the side in a constant pattern (looks like this: ..... ).
I found that I can't use the "length" variable for the repeating pattern function since it isn't an "integer", so I wanted to know if there is a way to convert the "length" to an "integer" like how one would convert an integer to a double using in java or python.
I found that I can't use the "length" variable for the repeating pattern function since it isn't an "integer", so I wanted to know if there is a way to convert the "length" to an "integer" like how one would convert an integer to a double using in java or python.
0
Best Answer
-
chadstoltzfus Member, Developers, csevp Posts: 142 PROLength variables are given a data type known as ValueWithUnits, and are represented in FeatureScript as value * unit (4 * in). Even though in Part Studio/configuration variables they are displayed as something like "4 in", they still have the type ValueWithUnits and are pretty much just multiplying a number by a conversion value.
To convert a ValueWithUnits to an integer (or a number in this case), simply divide the ValueWithUnits by the unit you want to get.
For example, doing 12 in / mm will get you 304.8, while doing 12 in / in will result in just 12.
Applications Developer at Premier Custom Built
chadstoltzfus@premiercb.com1
Answers
To convert a ValueWithUnits to an integer (or a number in this case), simply divide the ValueWithUnits by the unit you want to get.
For example, doing 12 in / mm will get you 304.8, while doing 12 in / in will result in just 12.
chadstoltzfus@premiercb.com