Hi Guys...I have a doubt. I need to change the valve color based on the tags (Run,Fault,etc.). I'm Using nested IF expressions, but since the valve has too many elements. I can't manage it all in one expression.
Use binEnc | Ignition User Manual to combine all the booleans into an integer.
Use a Map Transform to convert the integer to a color. Note the Output Type setting.
I have a valve from Symbol Factory that consists of many individual elements. I need to change the color of the valve based on its status. Since the valve is made up of multiple elements, where should I write the expression to control the color for all elements?
Can’t speak for perspective, but in Vision, when using symbol factory symbols, I just copy the style to each sub component that needs to change color.
I haven't done it, but a quick look at the structure suggests that you need to expand each element and look for the stopColor
value or the fill
value. You then need to create a binding on each of these. Note that any gradient fills probably have at least three stops.
To prevent early onset madness, I suggest that you define the colors for each state as a session variable so that the color definitions can easily be redefined without having to revisit every valve. Something like:
- Then put a custom prop on the valve. e.g. 'colorPalette'.
- Add an expression binding to it to return the
{session.custom.valvePalette.open}
object when the valve is 'open', etc. - Create a Property Binding on each of the pump SVG colors to the appropriate value. e.g.,
this.custom.colorPalette.solid
It's a bit of work but you only need to do it once.
Further reading.