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.

Cannot use expression with multiple variables

Dario MangoniDario Mangoni Member, Developers Posts: 15 EDU
I have two variables of 'length' type.

If I set a dimension as #woodWidth or #tireDiameter they both work fine,
but as soon as I use

#woodWidth*#tireDiameter

I get the message "Insert a valid expression"

Why is that?
I also tried with #woodWidth*1*#tireDiameter.
I also made sure to have same measurement units.

What's happening?

Comments

  • john_mcclaryjohn_mcclary Member, Developers Posts: 2,960 PRO
    edited August 11
    Values with units suck, I try not to add units until the last step.

    You will need to remove the units of all but 1 variable

    Ex:
    X=12 in
    Y=2 in
    Z=3 in

    A=#x/in * #y/in * #z

    #A=72 in


    Or you can create a new variable as type 'any'
    A=#x*#y*#z

    #A=72 in
  • Dario MangoniDario Mangoni Member, Developers Posts: 15 EDU
    Thanks a lot. Good to know!
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 993
    When you multiply two lengths, you get an area, not a length.  This is to help catch formulas that are wrong because units don't match up, like adding a meter to a kilogram.  See e.g. https://en.wikipedia.org/wiki/Dimensional_analysis -- the dimensional homogeneity section.
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
  • mahirmahir Member, Developers Posts: 1,027 ✭✭✭✭✭
    Values with units suck, I try not to add units until the last step.
    Personally, I prefer enforcing units. It's less flexible in some ways, but if done properly it saves a lot of hassle downstream. It just requires a little forethought. Scaling factors should be unitless, but actual dimensions should have real units. This way I don't need to remember whether I used metric or imperial, deg or rad. The unit conversion math happens in the background. And as @ilya_baran mentioned, it prevents you from creating nonsensical formulas with inconsistent units.
  • Dario MangoniDario Mangoni Member, Developers Posts: 15 EDU
    I realized that there was an issue on my equation.
    The example was just a piece of it.

    I agree on the unit enforcement.

    Thanks a lot
Sign In or Register to comment.