Example: How to create new graphical object.

<< Click to Display Table of Contents >>

Navigation:  Project > Screens > User-defined library >

Example: How to create new graphical object.

Previous pageReturn to chapter overviewNext page

Let's create an object pump that consists of 2 simple objects: Ellipse and Polygon:

ellipseandpolygon

Let's group these objects:

pumpgroup

Let's add 3 tags in our project:

tagsellipse

We want that color of the ellipse is bound to the tag with name like this: Pump{number}State. Where {number} is number of the instance. And also we want that when user click on the object popup window is appeared with state information and description. Popup window looks like this:

pumppopupwindow

Where objects with name PumpState and PumpDescription (texts of these objects are similar objects names) will display state information of the pump and its description.

For the ellipse object let's create user-defined properties - number and description. To do this you have to double click on the Ellipse object (or choose Object properties menu item from context menu) in Screen window:

openellipse

Object properties window is appeared:

ellipseproperties

Click User-defined Collection button and add our properties:

ellipseudproperties

 

 

Then close this window and close Object properties window by clicking OK to confirm your changes. Now reopen Ellipse properties and open Fill color tab:

ellipsefillcolortab

To setup indirect tag's value click "..." and write Pump{number}State where {number} our user-defined property:

indirectagname

Click OK and close Choose tag window. Because user-defined property "number" equal 1 the property Fill color for the object is bound to the Pump1State tag:

fillcolorellipse

Click OK to close Object properties window. Now let's test functionality. Run simulation and change Pump1State value from false to true:

testfunctionality

To call popup window let's create object type script:

callpopupscript

This script we add to the scripts of the ellipse:

addscripts

The text of the script looks like this:

scripttextexample

Now when you click on the ellipse of the pump you'll see the window (depending on the tag value). You can create other pump instance and change user-defined property number to 2 or 3 to bind pumps to Pump2State and Pump3State tags. And you can change description property for every pump's ellipse:

popupwindowrun

Attention! Maybe it's better to use Polygon for holding user-defined properties and click action, because it's over the Ellipse. Or like option you can use transparent rectangle over the whole group object and use it's click action.

Now we can add this graphical object to our library:

addtolibrary2

Now let's open Add graphical object window and find our library. Right click on it and choose Export library plus menu item. File dialog box will be appeared. Enter name of the library and click Save. This library will be save with out object and also saved script we created in this project and popup window. Now if you want to use this object with these popup window and script just import to other project.

Important! In the new project you have to create the same tag names.