Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

IF vs IIF in Equations

Status
Not open for further replies.

CorBlimeyLimey

Mechanical
Nov 5, 2003
15,292
Just discovered the IF operator can now be used in SW12, as opposed to the IIF operator in previous versions.

SW11
You can also use the Visual Basic IIf function when specifying a model dimension. This function returns one of two values depending on the evaluation of an expression. For example, if the equation specified is "D1@Sketch1" = (IIf("D1@Sketch4">15, 20, 10)) + 8, then:

SW12
You can also use the Visual Basic If function when specifying a model dimension.

This function returns one of two values depending on the evaluation of an expression.

For example, if the equation specified is "D1@Sketch1" = (If("D1@Sketch4">15, 20, 10)) + 8, then:

Anyone know of other changes?
 
Replies continue below

Recommended for you

I don't have SW12 installed yet, but my guess is that since the syntax is completely unchanged other than changing IIf to If, nothing is really changed. All equations actually get evauluated as a line of VBA code. SolidWorks already looks for certain strings in the equation (dim names, custom prop names, etc) and replaces them with something else (a number/value) before handing them off to the VBA interpreter. They just added " If(" to the list and replace it with " IIf(" before handing it off to the VBA interpreter. They probably did that because too many people didn't understand why they spelled "if" with two 'i's. :)

See what happens with the equation:

"dummy" = MsgBox("Hello World If(")

It wouldn't surprise me one bit if you got a message box that says:

Hello World IIf(

-handleman, CSWP (The new, easy test)
 
I couldn't even get that to be accepted in the editor.
It's totally different now.

download.aspx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor