Creating dynamic colors


I am working on a new project with Ignition 8.1.24 Vision.

I would like to know if there is a nice way to create reusable colors for template animation. For example :
I would like to make a library of symbols (motors valve, digital value, etc)
I already have udts containing the necessary tags for the animation.
Now, I would like to define a series of colors which I want to use on my templates so if for any reason i wanted to change a red 255,0,0 to a 240,0,0, I can do it easly and it applies on every template.

Is this possible? And how?

Additionally, is there a way to copy-paste animation from a circle to a rectangle or any other object easily?

Thanks you.
Best regards.

Best way for colours is either using client tags to store hex colours as strings, or using a project library to store colours as strings in a library variable, and retrieving these in your bindings using runScript.

However, I would recommend also using a dataset tag (or script dictionary) to store lookup values against colours to use, and then use this in your component bindings to get the colour.

For example, I have a status desc tag in all of my device udts which is an expression tag using case to get the status of the device as a string (Running, Stopped, Faulted, etc). Then my dataset tag has columns value and styleClass (perspective, but you can do similar for Vision).
Then my binding to get the colour is:

Lookup({System/Datasets/Style Classes/Device Status}, {status desc tag path}, '', 'value', 'styleClass')

This way essentially templates your map transforms and allows your maps to reside in a single place, rather than having a gazillion magic case statements everywhere doing colour mapping. Of course, in Vision it's slightly less nice if you use a dataset tag, as your colours will still be magic. But at least you will have far fewer copies and youll know they're all just inside of the few dataset colour maps that you have

Example data in the dataset:

value, colour, styleClass
"Running", "0, 255, 0", "Device/Status/On" 
"Stopped", "128, 128, 128", "Device/Status/Off"  

You would probably use the java.awt.Color data type for the colour column

1 Like

Ty for your quick answer.
I will try you solution as soon as possible, but As I see it now, the dataset with the colour inside sounds good.

Thank you very much.

I did a project this way and found it pretty easy to use. I also used the color picker popup to allow for some user customization on the "options" screen (which came in handy when the first operator I trained was color blind).

I'm sure you could use a binding to the dataset to do the same, but it may (or may not be) as simple.

The trouble with binding tags is that you're forever having to retype or repaste the map (eg the case statement) which I never liked. I know with a dataset lookup it's copy pasting still, but with a dataset it's exactly the same copy with only the lookup value part that changes. You don't have to change the mapping, for example for valves that use Open and Closed instead of Stopped and Running; you just add these states into your dataset tag and it starts working. As a bonus, you then also have a full list of all possible states of a device listed in one spot, which may or may not be useful



So I tried several think but nothing do the job as I would like to...

I do have implemented a memory tag dataset with my colours inside.
This is not usable in style customization as the Style Customizer doesn't allow bindings of colours.

I have tried to edit Fill Paint with the colour from my memory tag but this doesn't allow blinking so I gave up that solution.

I have gone one step further and created a memory tag dataset containing exactly the "Styles" property issued from the Style Customizer. Then binded the Styles property to this tag. This does work but...

  • The blinking is not synchronized on the different template instance as the blinking "beginning" is based on the tag change so my screen looks like a rainbow christmas tree :stuck_out_tongue:
  • Also, the Style Customizer editor isn't compatible with this kind of bindings...

So I have searched Ignition Forum for that problem once more. I have found similar issues but no real solution...
My current idea is to create a boolean tag with a frequency of 1 Hz or so to use in my "State" variable (which is used in the Style Customizer) but I am afraid that Ignition will not like that too much performance-wise..
Also this doesn't change the fact that the Style Customizer "broke" when binding the Styles property...

[Edit] The Styles Customizer is not compatible if binded to a parameter because the parameter because in template edition the parameter has no value. If I bind it to a specific tag it does work.

Any idea?


Style customizer does allow binding of custom colors. It requires a cell update binding on the styles table. You may have to use toColor()

Oh, didn't knew about this kind of bindings. Thanks for the information.
Unfortunately, I am a bit lost as how to do it.
I have found the specific windows to setup the cell update binding. But at the moment my colours are in a dataset tag and I don't know what to input in the "Value" cell of the Cell Bindings. If I use the Property selector, I have something like this :
Which refer to the dataset containing my colours, which is obviously not right. How can I refer to a specific row and column in my dataset?

In any case, this will not solve the problem with the asynchronous blinking but it's good to now.

Use individual tags for your custom colors. Then you can select the state and property and add it to the cell update binding. Then your value would be toColor({customColorTag}). I haven't used the dataset method, so @nminchin would have to give you a hand with that. You might be able to access it via toColor({colorDataset}[0,3]) - just a guess though.

If you use a style customiser with blink, you won't be able to sync the blinks between components. The only way to sync them is to use a clock signal, eg a client expression tag using an expression with now in it.

1 Like

Have you noticed this to be a huge issue with your end users? To me, blinking out of unison isn't that big of a deal. But, I assume to others it's flat out annoying.

IMO it shouldn't be an issue. It might be a slight annoyance, but it does what it's supposed to do. Draw your attention to something that is wrong.

1 Like

Well it's impossible to do in Perspective nicely (i.e. with P Styles), so I've learnt to not be bothered by it, but when I first came to Vision from other platforms where they were sync'd, it bothered me to no end haha.

1 Like

I must I have seen the async blink for about 10 second and it has annoyed me quite a lot...
So have made the blinking tag and synced my template with it, it's less clean code but it's worth it to my opinion and to the option of my colleagues as well.

I must say I miss the colour management of the concurrence with dynamic/blinkable colour palette. usable everywhere.

So, here is what I have finally done :

  • I have an UDT containing :
    -- a Memory Dataset of columns Index (Int), Description (String), Color (Color) containing all possible animation used by Styles customizer
    -- a expression tag for each color usable outside of Styles customizer referencing the dataset. This way it's easier to use for single color references
    -- a memory tag for each color NOT used in Styles customizer for background of popup windows for exemple of for unanimated element.
  • I have another UDT containing blinking tag
  • In every animated object, I have create an int containing the reference Index of the color Dataset. Additionally, I use the appropriate blinking tag to change this value. This int is used in the Style customizer as long as the color dataset

This wait every color I use several times is referenced in that UDT and if I wanted, I could create an editor and make it available to the user so he could change the colors.