Entry type: FAQ, Entry ID: 24074628, Entry date: 06/03/2015

How can you display/hide a layer in a screen depending on a tag?

  • Entry
  • Associated product(s)
Depending on the status of a tag, a specific layer of a screen must be shown. This entry provides you with a script for this.

You can use the VBS script below, in which you only have to change the screen name, the layer, the tag and its value (for example, in a global VBS script or in a VBS action of an event of a button etc.).

This script functions only if the relevant screen is also open.

Dim Tag
Dim scrObj

Set scrObj = HMIRuntime.Screens("@Screen.@win12:@1001.@Desk:screen_name")
Set Tag = HMIRuntime.Tags("Tag")


If Tag.Value = 0 Then
scrObj.Layers(screen_layer).Visible = False
scrObj.Layers(screen_layer).Visible = True
End If

Note (taken from the WinCC Online Help)
Upon access, the layers are counted in VBS starting with 1. Thus layer "0" in the WinCC Graphics Designer must be addressed with layers(1).

For example, if you want to address screen layer 10 in a screen, you must enter
11 for scrObj.Layers(...).Visible.

If you have opened a screen on anther monitor, you must address it accordingly, "@Screen.@win22:@1001.@Desk:screen_name", for example. More information about the addressing of different monitors is available in Entry ID: 831486.