There seems to be a bug in the way Dynamic Component evaluates the results of an “IF” function. It appears to be evaluating the implied “then” section, even when it should not because the condition has already been met.
For example, I am trying to avoid a “division by zero” error by checking if the divisor is zero first, then only doing the math if it is not, yet the math gets done anyway, and thus I get the “DIV/0” error regardless!
Here’s the simplest possible way of reproducing this bug. Create two attributes:
ThisIsZero = 0
ThisIsZeroCheck = IF(ThisIsZero=0 , 1, 100/ThisIsZero)
The final part of that should never be evaluated (thus avoiding the error) since the attribute “ThisIsZero” is in fact zero, so it should never attempt to evaluate “100/ThisIsZero” … yet SketchUp evaluates it anyway, and reports “DIV/0”. The evaluation should stop at the first term, as soon as it figures out that “ThisIsZero” has a value of zero, and return the value “1”. There is no need to evaluate anything further, since the condition has been met.
It also occurs to me that if SketchUp really is evaluating every part of every “IF” function in a model, including the parts that are not relevant, that would go a long way to explaining why it is so slow on large, complex models! The speed could increase quite a bit if it didn’t bother evaluating things that don’t need evaluating…
Either that, or there’s something major that I’m missing here! Why would it return a “DIV/0” error, when it should not even be trying to do that, because the condition for doing so was not met?