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.

Options

Addition and Subtraction in equations in Part Studio

joel_smith140joel_smith140 Member Posts: 4
Greetings!  I'm trying to use equations with a declared variable while dimensioning a part, but can't seem to get the editor to accept addition or subtraction as valid entries.

For example, I'd like to place a point for a hole that is 1 inch to the side of the center of my part.  I'm able to place the point at the center point with the following set-up:


But if I try to use a "+" or "-" sign, the equation box turns red and it won't accept the equation.



I have tried to complete this operation with and without parentheses.  I have also tried to use "-1 + (#BaseWidth/2)" and "1 + (#BaseWidth/2) thinking that I might be able to accomplish it with addition, but no luck.  Is there a way to utilize addition and subtraction in this environment, or are we restricted to multiplication and division. 

Thanks for your assistance!

Comments

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,717 PRO
    Try (#BaseWidth/2) + 1in

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    tim_hess427tim_hess427 Member Posts: 648 ✭✭✭✭
    In general, things like this usually come down to how units are handled. Onshape know that the units for "#basewidth/2" will be the same as the units for "#basewidth". Example: 4in/2 = 2in. It won't assume to know units when adding or subtracting, though. So, you have explicitly tell it to add 1in.  

    This also gives you the flexibility to mix units where it makes sense, as well. If my workspace units are mm, but I know something needs an offset of 1.5in to accommodate an off-the-shelf component, I can do something like "30mm + 1.5in" and it'll work out. 


  • Options
    Alex_KempenAlex_Kempen Member Posts: 244 EDU
    The issue you're experiencing is with units. In most cases, units on dimensions are assumed according to your part studio settings, but when adding and subtracting, both sides of the equation must have the same type of unit, so (2 + 3) and (2 * inch + 3 * foot) works, but (2 * inch + 3) does not. So, since the right side of your equation has units (#BaseWidth / 2 has length units of some kind), and the left side does not (-1 is unitless), the equation fails. 

    I would also recommend taking a look through the help article on fields here. There's actually a lot of interesting things in there - for example, it's possible to use the ternary operator (?) in fields, which can be occasionally helpful when doing configurations. 
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • Options
    joel_smith140joel_smith140 Member Posts: 4
    That fixed it!  Thank you all so much for your quick replies!
Sign In or Register to comment.