Executing color script based on the color of another element

Hi, Im looking for a script for changing the color of a line based on the color of the previous line/pipe and the status of a breaker between them.
Something like this for the color of the cord2: " if ({[breaker1.open}), color({cord1.strokePaint}), color(0,0,0).


Be cautious doing this for long lines of components. A colleague of mine went down this route for pipework on a P&ID layout and from memory it made performance slow, I presume because the bindings become less and less efficient the deeper the chain you go. Usually if you have multiple components that use the same binding, these will only be bound once and then that binding is referenced by the other components. I’m not sure this is the case with chained bindings.

Regardless, if you want to do this, you would use something like:

if({Root Container.breaker1.open}
  ,{Root Container.coord1.strokePaint}