How-to
How WinCC visibility animations hide and show objects at runtime
Short answer
A layer you hide in the editor stays visible at runtime, because layers are an engineering arrangement, not a runtime command. To hide and show objects while the panel runs, bind a visibility animation to a tag and toggle it with an invert bit button, or flip each object's Visible property from a VB script. For overlapping indicators with priority, the lower-priority object's show range must exclude the value that means the higher-priority condition is active.
On this page
- Why do objects I hid in a layer still show on the panel?
- How do I toggle a group of objects with one button and an internal tag?
- Which fields does the visibility animation need?
- Why does my button show the opposite of what its label says?
- How do I hide and show objects with a VB script instead?
- How do I keep one overlapping indicator in priority without PLC code?
- What can a visibility animation not do?
- Questions asked
Hiding a layer in WinCC (TIA Portal) changes only what you see while engineering the screen; the panel still shows every object on that layer at runtime. Runtime hide and show works per object, through one of two documented paths: a visibility animation that watches a tag, or a VB script that writes each object's Visible property. The sections below build the tag-and-button toggle on an internal Boolean tag, the script variant, the range arithmetic that gives one of two overlapping indicators priority without PLC code, and the point where visibility stops and real interlocking begins.
Why do objects I hid in a layer still show on the panel? #
A layer is an engineering grouping only: the editor uses layers to organize drawing and editing, and WinCC (TIA Portal) provides no runtime function that shows or hides a layer, so hiding one changes nothing about which objects the panel displays.
Layers answer how to keep a screen manageable while you draw it, not what the operator sees. The panel has no layer state to read and no function to write one, so a screen whose compact layout depends on hidden layers shows everything the moment the project boots. The runtime mechanisms live on the objects themselves: the visibility animation listed under each object's Properties > Animations page, and the Visible property a script can write through the screen's ScreenItems list. Decide early which objects form the toggle group, because the command addresses objects one by one, never the layer they were drawn on. Decision: treat layers as an editing tool only, and build every runtime hide/show on object animations or scripts.
How do I toggle a group of objects with one button and an internal tag? #
Build the toggle from three pieces: one internal Boolean tag, one button whose press event runs the invert bit function on that tag, and a visibility animation on every object in the group that makes it visible while the tag reads zero.
The configuration below was built on WinCC Comfort V13 SP1, and the fields and names are the ones the editor shows:
- Create an internal Boolean tag. The sample names it HMI_Tag_1. An internal tag lives in the HMI project and needs no PLC address, which keeps the toggle entirely inside the panel.
- Create a button on the screen and attach the invert bit function to its press event, with HMI_Tag_1 as the target. Each accepted press flips the tag between 0 and 1.
- Mark every object that belongs to the group on the screen with the mouse plus Shift.
- In the Inspector window, open Properties > Animations, select Visibility and add the new visibility animation to the selection.
- Fill in the row: Process tag HMI_Tag_1, Range From 0, Range To 0, and the visibility action set to Visible.
- Start the runtime and press the button. The group hides while the tag reads 1, reappears at 0, and every object outside the group stays unchanged.
An internal tag fits here because the hidden-details choice is operator preference, not machine state. If several screens should honor the same toggle, keep one tag for all of them rather than a private tag per screen, or the screens will disagree about what is hidden. When the decision belongs to the controller instead, the same animation accepts a PLC address — the walkthrough that shows an HMI button only when a PLC bit is high binds the identical row to a PLC tag. Decision: use this method whenever one state governs the whole group and a button press is the whole logic.
Which fields does the visibility animation need? #
Four entries decide the entire behavior: the process tag that carries the command, the From and To values that select the state the row matches, and the visibility action, which the sample sets to Visible.
| Field | Sample entry | What runtime does with it |
|---|---|---|
| Process tag | HMI_Tag_1 | Every object in the selection reads this one command tag |
| Range From | 0 | Lower edge of the value range that matches the row |
| Range To | 0 | Upper edge of the matching range |
| Visibility | Visible | Object shows while the tag value sits inside the range |
A Boolean tag only ever produces 0 and 1, so a range from 0 to 0 makes 0 the visible state and 1 the hidden one. Multi-selection writes this row into every object selected in step 3, but each object stores its own copy from then on; an object placed on the screen afterwards does not inherit it. Decision: the four entries are the whole configuration, so if an object later behaves differently, the difference sits in its own copy of the row.
Why does my button show the opposite of what its label says? #
The mapping decides the wording, not the button: with the sample row the group is visible at tag value zero and hidden at one, so any button on this tag is a toggle whose current effect depends on the value the tag already holds.
A caption such as "Show details" is therefore true only half the time. Two settings put it right. First, the tag's configured start value decides the state after every power-up, so set it to what the operator should see before the first press. Second, check the button's event list for a second inversion on the same action — a press event and a release event that both invert the tag return it to its starting value in one touch, and the button looks dead. Decision: word the caption as the toggle it is, or bind a small indicator object to the same tag so the screen shows the current state.
How do I hide and show objects with a VB script instead? #
A script toggles each object directly: it addresses the screen by name, picks each screen item by name and flips the Boolean Visible property, which lets one press change four differently named objects without a shared tag or any animation.
Sub VBFunction_1()
Dim aaa
Set aaa = HmiRuntime.Screens("Root screen").ScreenItems("Circle_2")
aaa.Visible = Not aaa.Visible
Set aaa = HmiRuntime.Screens("Root screen").ScreenItems("Text field_2")
aaa.Visible = Not aaa.Visible
Set aaa = HmiRuntime.Screens("Root screen").ScreenItems("Rectangle_2")
aaa.Visible = Not aaa.Visible
Set aaa = HmiRuntime.Screens("Root screen").ScreenItems("I/O field_2")
aaa.Visible = Not aaa.Visible
End Sub
HmiRuntime, ScreenItems and the Visible property are the runtime object names the scripting environment documents. VBFunction_1, Root screen, Circle_2, Text field_2, Rectangle_2 and I/O field_2 are the sample project's example names: replace them with your screen's and objects' configured names from the project tree, not the captions the operator reads. Attach the script to the button's click event, as the sample attaches VBFunction_1 to the mouse click. The runtime test proves the wiring: one press flips all four objects, a second press returns them, and any object the script never names stays on screen.
A script reaches only the screen it addresses, so when an object lives on a screen that is not currently open, the notes on WinCC VBScript access to ScreenItems from an inactive screen cover what the runtime returns. Decision: take the script when the objects share no single state tag, when the hide/show follows logic or arithmetic, or when you want one fixed name list to flip from one place.
How do I keep one overlapping indicator in priority without PLC code? #
Give the lower-priority object a show range that excludes the higher-priority state's numeric value: with two condition bits packed in one integer tag, Circle_1 shows for values 1 to 3 while Circle_2 shows only for 2, so the both-bits-set value 3 keeps Circle_1 alone on screen.
Worked example: both conditions arrive as two bits of an integer tag the controller already delivers — call it Indicator_Word in this example. Give Circle_1's condition bit the weight 1 and Circle_2's the weight 2. The tag can then read 0 (neither condition), 1 (only Circle_1), 2 (only Circle_2) or 3 (both), because 1 + 2 = 3. Configure one visibility animation per object on that tag:
| Object | Range From | Range To | Action | The row matches when |
|---|---|---|---|---|
| Circle_1 | 1 | 3 | Visible | its bit is on, whatever Circle_2's bit does |
| Circle_2 | 2 | 2 | Visible | its bit is on while Circle_1's bit is off |
When both bits set at once the tag reads 3. That value sits inside Circle_1's range of 1 to 3, so Circle_1 shows; it sits outside Circle_2's range of exactly 2, so Circle_2 hides. Priority comes from the range arithmetic, not from which object is drawn on top, and the PLC keeps its old code. Scope both ranges to the values the two condition bits can produce; if the delivered word carries other bits, fold the two conditions into a dedicated internal integer first. That fold also covers conditions arriving on two separate Boolean tags: a single script line maps the pair onto the same weights, and the same two ranges apply.
The rule behind the table — the second object shows only when its own condition is active and the first one is inactive — is the same construction built step by step in the walkthrough on an A and not B visibility condition in EasyBuilder Pro. Decision: build the exclusion into the losing object's range, and priority holds for every value the tag can take.
What can a visibility animation not do? #
Visibility is presentation only: hiding an object removes it from the screen but grants no permission, creates no interlock and blocks no command, so a machine safety function must stay in the controller and the wired safety circuit, never in an HMI animation.
Hiding a button that triggers a machine function does not disable the command path behind it; the animation decides pixels, not permissives. Decision: treat every change in this article as screen behavior, and keep interlocks, access control and safety functions in the controller and the wiring, where an animation cannot reach.
Questions asked
Will the hidden state survive a panel power cycle?
Only if the tag is configured to retain its value. A non-retained internal tag returns to its configured start value at every restart, and with the sample mapping that start value decides what shows after power-up: 0 shows the group, 1 keeps it hidden. Set the start value and the retention behavior to match what the operator should meet after a restart.
Can one VB script reach objects inside a faceplate instance?
Not with the sample approach. ScreenItems resolves objects by their configured names within the screen you address, and the internal objects of a faceplate instance are not screen items of the parent screen, so a script that walks the parent screen stops at the faceplate border. Use the property access your faceplate instance documents, or animate the objects inside the faceplate with a visibility animation instead.
Which WinCC targets run this kind of VB script?
The essential Visual Basic commands are documented for WinCC Runtime Advanced, WinCC Runtime Professional and operator panels running Windows, so the scripting style is not limited to one panel family. Check your exact target's scripting support and its runtime object model in the target documentation before copying the sample to it.
Why do only some of the objects I selected start toggling?
Multi-selection writes the animation into the objects selected at that moment, and each object keeps its own copy afterwards. Objects added later, or ones that already carried an older animation, can still point at a different tag, a different range or the opposite visibility setting. Open each object's animation list and confirm the same process tag, the same From and To range and the same Visible action.