Complex color change

<< Click to Display Table of Contents >>

Navigation:  Examples > Change the color of an object >

Complex color change

Previous pageReturn to chapter overviewNext page

If your project contains several objects of the same type, then to speed up project development, it is advisable to use non-unambiguous names when binding tags, but tag names associated with keywords based on user-defined properties. Let's create several tags for our example:

tagsforcomplexexample

Let's create Motor graphical object for our example:

motorexample

Let's open Object properties window by double clicking on it:

motorpropertieswindow

And let's create user-defined property - Number and make it's equal 1:

complexudp

Close Collection window and then confirm creation of user-defined property by clicking OK on Object properties window. Then reopen Object properties window and enable Fill color property on the tab:

complexfilltab

Now we need to bind Tag to the tag with name depending on our property - Number. To do this click "..." and in Choose tag window enter State{Number} in the Tag name field where Number is our user-defined property:

choosetagcomplex

Now Fill color property bind to State1 tag and we need to change color depending on this tag's value:

State1

Color

0

RED

1

GREEN

2

YELLOW

To do this change Type to Tag.PV in the range:

complexfilltab2

And fill Ranges:

rangecomplesflash

Confirm changes and close Object properties window by clicking OK. Now we have Motor with setup Fill color property. To copy this Motor and bind Fill color property to tags - State2 and State3 you no need to setup Fill color property for every Motor you only have to duplicate Motor:

 

complexduplicate

And change Number property of the new Motor in the Property sheet:

complexpropertysheet

Click OK to confirm your changes and Run simulation to check your settings:

complexrunsim