Mimic.Layers
The Mimic.Layers property can be used to allow a script to access the Layers on a Mimic. By using the Mimic.Layers property, you can access the individual properties of each Layer, which include the properties of each item on that Layer. You can also use a For Each In statement to iterate around a collection of Layers.
Syntax |
For accessing the visibility property (Visible) of a Layer, the syntax is: Mimic.Layers (Layer Name or Index Number).Visible If the Layers property is being used to access the properties of an item on the Mimic Layer, such as the properties of a shape, the syntax is: Mimic.Layers (Layer Name or Index Number).Item("Item Name").Object Property The Object Property is the name of one of the item's animation properties, for example, Text is the name of an animation property for a text box item. You can access any animation properties for an item in this way, and some items have additional properties that you can access see Animation Properties for Mimic Items on Layers. |
Description |
Provides access to the properties of the Layers on the Mimic that contains the script. It can also be used to access the properties of the Mimic objects on the Layers. |
Arguments |
Layer Name {string} This has to match the name given to the Layer during its configuration. Index Number {integer} This value is allocated to the Layer automatically. The number of a Layer corresponds to its position in the list on the Layers window. The Layer at the top of the list has Index Number 0, and the other Layers are ordered decrementally, which means the next Layer in the list has Index Number 1, the next Layer has Index Number 2 and so on. Layer Property {string} The name of the Layer property that the script is to reference. Each Layer has a Visibility property and an Items property. The Visibility property determines whether the Layer can be seen (True = visible; False = hidden), and the Items property is used to access the properties of individual shapes, text boxes and so on on the Mimic Layer. Item {string} The Item property provides access to the properties of individual objects on a Layer, for example, the properties of a shape. Item Name {string} This value has to match the name of the object's property. You cannot reference a property of a Mimic object by Index Number. Object Property {string} The name of the Mimic object property that the script is to reference. Each Mimic object has its own properties. The properties that are available for use in a script are the same as those that are available for use in animations (see Animations in the ClearSCADA Guide to Mimics). |
Returns |
Variant. The value that is returned is dependent on the type of property being accessed. |
Example:
In this example, the Mimic.Layers property is used to access the visibility property (Visible) of each Layer. This allows the script to hide and show the different Layers. In this case, the script shows or hides a Layer depending on whether an appropriate button is selected.
The Mimic has the following Layers:
- Front—Contains the buttons and the title. Each button is associated with a script pick action.
- Tank1—Contains the tank image and point value on the left.
- Tank2—Contains the tank image and point value in the middle.
- Tank3—Contains the tank image and point value on the right.
- Back—Contains the background object (in this case, a white rectangle).
The following script is used to provide the hide/show functionality:
- Sub ToggleLayer1
- If Mimic.Layers(1).Visible = True Then
- Mimic.Layers(1).Visible = False
- Else
- Mimic.Layers(1).Visible = True
- End If
- End Sub
- Sub ToggleLayer2
- If Mimic.Layers(2).Visible = True Then
- Mimic.Layers(2).Visible = False
- Else
- Mimic.Layers(2).Visible = True
- End If
- If Mimic.Layers(1).Visible = True Then
- End Sub
- Sub ToggleLayer3
- If Mimic.Layers(3).Visible = True Then
- Mimic.Layers(3).Visible = False
- Else
- Mimic.Layers(3).Visible = True
- End If
- If Mimic.Layers(3).Visible = True Then
- End Sub
The first sub routine is named ToggleLayer1 and it references Layer 1's Visible property:
- If Mimic.Layers(1).Visible = True Then
- Mimic.Layers(1).Visible = False
- Else
- Mimic.Layers(1).Visible = True
- End If
The Layer is being referenced by its Index Number, in this case, 1. The Index Number corresponds to the Layers position on the Layers window, with the Layer at the top of the list having Index Number 0, and the other numbers being allocated in descending order, so the next Layer on the list has Index Number 1, the next Layer Index Number 2 and so on. Alternatively, the Layers can be referenced by name, with the name being entered as a string, for example:
- Mimic.Layers("Tank1"). Visible = Truep
The script defines that if Layer 1's Visible property is True i.e. Layer 1 is currently on display, the script will change the Visible property to False when executed (hide the Layer). If Layer 1's Visible property is False, the script will change the Visible property to True so that Layer 1 is displayed.
The button on the left ('Show Tank 1') is associated with the ToggleLayer1 sub routine. This means that when the button is selected, it will toggle the visibility of the Tank1 Layer (hide/show the tank image and point value on the left).
The ToggleLayer2 and ToggleLayer3 sub routines work in the same way as the ToggleLayer1 sub routine, except that they toggle the middle tank image and point value and the right tank image and point value respectively. The middle button ('Show Tank 2') is associated with the ToggleLayer2 sub routine and the right button ('Show Tank 3') is associated with the ToggleLayer3 sub routine.
So, when the 'Show Tank 1' button is selected, it toggles the visibility of the 'Tank1' Layer, when the 'Show Tank 2' button is selected, it toggles the visibility of the 'Tank2' Layer, and when the 'Show Tank 3' button is selected, it toggles the visibility of the 'Tank3' Layer.
Selecting the 'Show Tank 2' button runs the 'ToggleLayer2' sub routine. This shows or hides the 'Tank2' Layer (which has Index Number 2) depending on whether the layer is already displayed/hidden.