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.

How do I change a the "length" variable to an "integer" variable in a different variable?

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.

Best Answer

  • chadstoltzfuschadstoltzfus Member, Developers, csevp Posts: 142 PRO
    Answer ✓
    Length 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.com

Answers

  • chadstoltzfuschadstoltzfus Member, Developers, csevp Posts: 142 PRO
    Answer ✓
    Length 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.com
Sign In or Register to comment.