SOLIDWORKS IIF equal’s to “the syntax is wrong” error workaround


Ever try creating an if-then statement in SOLIDWORKS to control a feature. Well if you ever want to then you need to use the IIF function. Yes there are two I’s.



The syntax of the Visual Basic IIf function is:  iif(expression, truepart, falsepart)



·expression is the expression you want to evaluate

·truepart is the value to use if expression is true

·falsepart is the value to use if expression is false



· The following equation suppresses a linear pattern when the value of global variable "overall length" is less than 40.

"LPattern1" = iif ("overall length"<40, "suppressed", "unsuppressed")


· This following equation unsuppresses a rib feature when a particular dimension is greater than 100.

"Rib1" = iif ("D3@Sketch1">100, "unsuppressed", "suppressed")



What SOLIDWORKS doesn’t like and will prevent from working is the equals sign used for an equal’s to syntax. Such as


“D1@sketch3” = iif (“D2@sketch1” = 0.5, 1.0, 1.25)


Work Around:

The workaround for this is to utilize the “double negative” syntax. Such as


“D1@sketch3” = iif (not(“D2@sketch1” <> 0.5), 1.0, 1.25)


Which is equivalent to “D1@sketch3” = iif (“D2@sketch1” = 0.5, 1.0, 1.25)



  • Share this
Find Your Design Solution in the CATI Store.
Browse Products