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.

Equation not working. Need help

Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
edited November 2017 in Community Support
I have this equation for a dimension using variables:

(245-((#ARC1+#ARC2)))/2

The first minus sign after 245 is the problem. When digging into this to see what is wrong, If I try a minus, plus, division operator it does not work. If I try a multiplication operator it does work. 

(245-((#ARC1+#ARC2)))/2 gives error "enter a valid function"
(245+((#ARC1+#ARC2)))/2 gives error "enter a valid function"
(245/((#ARC1+#ARC2)))/2 gives error "enter a valid function"
(245*((#ARC1+#ARC2)))/2 works

What am I doing wrong or is this a bug?

Best Answers

  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    Answer ✓
    Do either of the variables have units? It might be worth removing the units from the variables and adding them in the dimension instead.
    No units they are copy and pasted from the dialog

Answers

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    did you tried (245-(#ARC1+#ARC2))/2 or (245-#ARC1- #ARC2)/2 ?
  • abefeldmanabefeldman Member Posts: 166 ✭✭✭
    Do either of the variables have units? It might be worth removing the units from the variables and adding them in the dimension instead.
    Abe Feldman
    UX/PD/Community Support
  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    Answer ✓
    Do either of the variables have units? It might be worth removing the units from the variables and adding them in the dimension instead.
    No units they are copy and pasted from the dialog

  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    did you tried (245-(#ARC1+#ARC2))/2 or (245-#ARC1- #ARC2)/2 ?
    Neither of these work unfortunatley

  • lanalana Onshape Employees Posts: 705
    @Ben_
    Does (#ARC1+#ARC2) / 2 work?
  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    lana said:
    @Ben_
    Does (#ARC1+#ARC2) / 2 work?
    Yes that portion of the equation works but as soon as I try and subtract it from 245 is does not
  • abefeldmanabefeldman Member Posts: 166 ✭✭✭
    Testing this out I set

    ARC1 = 45 deg
    ARC2 = 45 deg

    All of the equations but the last fail because 245 does not have consistent units with either of the variables.

    Changing the variables to the "Any" unitless option succeeds:

    ARC1 = 45
    ARC2 = 45

    Or you could enter ((245*deg)-(#ARC1+#ARC2))/2, but be sure there's no "deg" unit appended to the end.
    Abe Feldman
    UX/PD/Community Support
  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    edited November 2017
    Testing this out I set

    ARC1 = 45 deg
    ARC2 = 45 deg

    All of the equations but the last fail because 245 does not have consistent units with either of the variables.

    Changing the variables to the "Any" unitless option succeeds:

    ARC1 = 45
    ARC2 = 45

    Or you could enter ((245*deg)-(#ARC1+#ARC2))/2, but be sure there's no "deg" unit appended to the end.
    I have not used degree units! The ARC1 and ARC2 are lengths defined only by a number in my document (FYI they are arc lengths not arc degrees)

  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    I need to eat a little crow now... In the end if I added mm to the 245 it works thus (245mm-(#ARC1+#ARC2))/2 works but (245-(#ARC1+#ARC2))/2 does not. 
  • Ben_Ben_ OS Professional, Mentor, Developers Posts: 303 PRO
    It would be nice if the variables defaulted to unitless. IMHO
  • JanaLumiJanaLumi Member Posts: 2
    edited September 13

    I'm having the same issue. Cannot remove the units from the variables, nor does it access units in the calculation.

    For example, in the calculation:

    ((#depth/#joins))-0.2) mm
    → this works

    (#depth/#joins)+#adj
    (#depth/#joins)+#adj mm
    → neither of these are accepted and I get the error message: "cannot subtract unitless number and length"

  • S1monS1mon Member Posts: 2,980 PRO
    edited September 13

    (#depth/#joins) is unitless.

    #adj has units.

    you could do (#depth/#joins mm)+#adj

    What you probably want to do is switch joins to be a number not a length. Then the equation would be #depth/#joins + #adj.

Sign In or Register to comment.