# Dynamic Component Issue - Did Basic Math Change?

Hello All,

I’m having some trouble with a dynamic railing component I’m working on. It’s not the usual suspects of the plugin dropping functionality halfway through the work process - well maybe it is.

For some reason the computer is… trolling me?

I’m having an issue where I’ve defined a function to set the length of a nested instance based on another value. So if the two ends of the railing are 1.5" wide, the length of the horizontal runner should be the total length-that value*2

Simple enough Right? There are 3 lengths I want it to consider so I set an IF/AND function which works somewhat. For 2 of the 3 railing ends it’s working perfectly. But for the first option it’s returning a value*100. If I add in a /100 to the formula it returns 0.03 (which is technically correct based on 3/100)… If I go to the Value/1 it returns 300 again.

I’ve attached screenshots below as well as the model for you to peruse. As a way of brute forcing the value I input 3" and it returned the value of 3"00 which is… i don’t even know what lol I even had a coworker look it over and he was flustered too.

Can anyone take a look and figure out why it’s returning the value so high? If it’s simply restarting sketchup (which means restarting my whole computer when the DC plugin quits working correctly) then I can do that too.

Thanks,

T.

Dynamic_Railings.skp (330.5 KB)

Just a quick look - the `&` is not a logical “and” in DC’s. I think it’s for string concatenation. Did you mean to do something like:

``````=AND(IF(cond1, value1, value2), IF(cond2, value3, value4))
``````

Or maybe just add the values:

``````=IF(cond1, value1, value2) + IF(cond2, value3, value4)
``````

Or an if/else if/else:

``````=IF(cond1, true_value1, IF(cond2, true_value2, false_value))
``````
2 Likes

When you have more then one IF() statement, I prefer to CHOOSE() (in combination with OPTIONINDEX())

Check the SketchUp functions here:
https://help.sketchup.com/en/sketchup/dynamic-components-sketchup-function-examples

Thanks guys. I’m still new to coding in general so I get the logic but the nuances of syntax is what gets me. Thanks for clearing it up. Adding them together worked like a charm. Thanks

T.