×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Equation math question
3

Equation math question

Equation math question

(OP)
I freely admit that math is not my strong suit. What I would like to know is how would I use a length dimension to control a angle dimension. For example, how would I apply a formula in the Equation Editor that takes a 1" length dimension and use it to control an angle dimension so that the angle dimension equals 45 degrees and a 2" length dimension so that the angle dimension equals 60 degrees. Seems like I need some kind of formula to do this. Is there a book that contains math formulas like these?  

RE: Equation math question

You need to use IF statements. Check excel help files more details on IF and similar formulas.

Deepak Gupta
SW 2010 SP4.0 & 2011 SP3.0
Boxer's SolidWorks™ Blog

RE: Equation math question

2
It depends on what the relationship between the length and angle really is.  if it's is random, then the IF statements will work for every length you can think of, but what happens when someone enters a length different than the IF statement?  

If it is linear like 1in->45deg, 2in->60deg, 3in->75deg, then the equation is y=m(x)+b or "D2@Sketch1"=15*"D1@Sketch1"+30 where D2 is angle and D1 is length.  

 

RE: Equation math question

(OP)
Really struggling with this as I do not have a programming background. Would it be possible to post an example of the syntax for "if" where a 1" length dimension makes the angle dimension 45 degrees.  

RE: Equation math question

In Excel, =if(L=1,45,60)

This says, if length=1, angle is 45, otherwise it is sixty.

Notice the angle will be 45 ONLY IF length is exactly equal to 1.

Don't know if this exactly meets your needs or not. If statements can be nested:

=if(L<1,30,if(L=1,45,60))

This says if length is less than 1, angle is 30, if length equals 1, angle is 45, if length is greater than 1, angle is 60.

Help is available in Excel.

Equation editor in SW has an if statement available, but for complex conditions you might be better off with Excel.

Regards,

Mike

RE: Equation math question

IF(logical_test, [value_if_true], [value_if_false])

Open Excel, go to Help > Microsoft Excel Help and type IF function in the Search field for more information.

RE: Equation math question

Here's what I've come up with (it's called a "nested if"):

"D2@Sketch1"=iif("D1@Sketch1"like 1,45,iif("d1@sketch1" like 2, 60, 10))

meaning set D2 to the following...
if D1 = 1, set D2 to 45

or else
if D1 = 2, set D2 to 60

or else (if D1 is not 1 or 2), set D2 to 10

(D2 is angle, and D1 is length)

 

RE: Equation math question

(OP)
I read what you wrote:

"D2@Sketch1"=iif("D1@Sketch1"like 1,45,iif("d1@sketch1" like 2, 60, 10))

I tried to make it even simpler to see if I could just get the "if" statement to work. I came up with this:

CylinderDiameter@Sketch1" = if("CylinderDepth@Cylinder"1,2, if("CylinderDepth@Cylinder" 2,3))

I get this error message:

"Equation entered is invalid"



 

RE: Equation math question

You missed the word "like" in your equation as applejack suggested.

Deepak Gupta
SW 2010 SP4.0 & 2011 SP3.0
Boxer's SolidWorks™ Blog

RE: Equation math question

Also, note that it is IIF, not IF.

-handleman, CSWP (The new, easy test)

RE: Equation math question

difficultone ...

Are you creating this equation in the Equations folder (use IIF) or Design Table (use IF)?

RE: Equation math question

(OP)
I figured iif was a typo -> wrong. I figured like was just a way to explain -> wrong.

Everything works now. I'm creating equations in the Equation Editor.

Where can I read more about the language and the syntax used for the Equation Editor? Are there any tutorial available with plenty of examples? Thanks to everyone who offered help.

 

RE: Equation math question

Equations use VBA.  Visual Basic for Applications.

-handleman, CSWP (The new, easy test)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources