Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equation math question 3

Status
Not open for further replies.

difficultone

Industrial
Jan 16, 2010
107
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?
 
Replies continue below

Recommended for you

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.

 
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.
 
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
 
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.
 
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)

 
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"



 
Also, note that it is IIF, not IF.

-handleman, CSWP (The new, easy test)
 
difficultone ...

Are you creating this equation in the Equations folder (use IIF) or Design Table (use IF)?
 
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.

 
Equations use VBA. Visual Basic for Applications.

-handleman, CSWP (The new, easy test)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor