Executing Picture Navigation via VBScript vs Standard Buttons in WinCC Graphics Designer

Executing Picture Navigation via VBScript vs Standard Buttons in WinCC Graphics Designer

To execute picture navigation from a static text or custom graphic in WinCC Graphics Designer using VBScript, assign the target PDL file to the BaseScreenName property for full-screen changes (HMIRuntime.BaseScreenName = "target.pdl"), or assign it to the PictureName property of a specific Picture Window (HMIRuntime.ActiveScreen.ScreenItems("PicWindow").PictureName = "target.pdl"). If the script fails, verify that the Picture Window name exactly matches the object name in the current active screen, ensure the '.pdl' extension is lowercase, and verify that the Picture Window 'Visible' property is set to True. Alternatively, use a standard Windows button with the Dynamic Wizard 'Picture Change' to eliminate script dependencies.

Table of Contents

WinCC Graphics Architecture: Screen Navigation Fundamentals

In SIMATIC PCS 7 OS and WinCC Graphics Designer, process visualization relies on picture files (.pdl). Screen navigation occurs in two distinct operational contexts:

  1. Full Base Screen Replacement: Replacing the entire process graphic viewport in the runtime workspace (e.g., navigating from Area Overview @Overview1.pdl to an operational plant graphic like Reactor01.pdl).
  2. Embedded Picture Window Switching: Retaining the master screen layout (such as title bars, alarm lines, and navigation docks) and swapping content inside an embedded picture container (PictureWindow / Bildfenster).

Choosing the incorrect object method in VBScript causes runtime navigation commands to fail silently.

VBScript Object Hierarchy in WinCC Graphics Designer

WinCC exposes the HMIRuntime object model to VBScript actions. The primary navigation properties operate as follows:

  • Full Screen Switching:
    vbscript HMIRuntime.BaseScreenName = "CC1CC1.pdl"
    This directly commands the root WinCC runtime container to load CC1CC1.pdl into the primary window.

  • Picture Window Switching:
    vbscript Sub OnLButtonUp(ByVal Item, ByVal Flags, ByVal x, ByVal y) Dim picWindow Set picWindow = HMIRuntime.ActiveScreen.ScreenItems("PictureWindow1") picWindow.PictureName = "CC1CC1.pdl" picWindow.Visible = True End Sub
    Here, PictureWindow1 must be the explicit ObjectName property of the picture window control residing inside HMIRuntime.ActiveScreen.

Root Causes of Scripted Screen Change Failures

When a VBScript navigation routine fails to switch screens, the fault typically traces to one of four discrepancies:

  1. Incorrect Object Targeting: In the user's script HMIRuntime.ActiveScreen.ScreenItems("CC1CC1"), "CC1CC1" was entered as both the control name and the target PDL. If no Picture Window named CC1CC1 exists on the active screen, VBScript generates an unhandled runtime error (Object required: ScreenItems(...)).
  2. Case Sensitivity and Filename Mismatches: WinCC runtime requires precise filename matching. If the file is named CC1CC1.pdl on disk, referencing "CC1CC1.Pdl" or omitting the .pdl extension on certain WinCC versions causes load failure.
  3. Missing Visibility Activation: If a Picture Window has property Visible = False, changing the PictureName property loads the file in memory but leaves the container invisible to the operator.
  4. Graphics Cache Lock: If the target .pdl was modified and saved without releasing runtime locks, WinCC fails to render the newly requested graphic.

Step-by-Step VBScript Implementation for Custom Objects

Follow this procedure to configure reliable navigation on any static text, polyline, or graphic symbol:

  1. Verify Object Names in Graphics Designer:
    - Open the host screen (e.g. MainView.pdl).
    - Click the container Picture Window and open its Properties window.
    - Confirm the attribute Object Name (e.g., pwMainContent).
  2. Configure Static Text Click Event:
    - Select the Static Text object.
    - In the Properties window, open the Event tab.
    - Expand Mouse > Mouse Click (or Press Left).
    - Right-click the Action column and select VBS-Action.
  3. Insert Clean Script Code:
    vbscript Sub OnClick(ByVal Item) On Error Resume Next Dim picWin Set picWin = ScreenItems("pwMainContent") If Not picWin Is Nothing Then picWin.PictureName = "CC1CC1.pdl" picWin.Visible = True End If End Sub
  4. Save and Test: Save the picture and launch OS Runtime to verify.

Standard Button with Dynamic Wizard vs Scripted Navigation

The table below contrasts standard button wizard configuration with custom VBScript navigation:

Navigation MethodConfiguration ToolScripting RequiredRuntime Execution SpeedMaintenance ComplexityDynamic Wizard (Picture Change)Standard Button + WizardNone (Pre-compiled C)Instantaneous (<10 ms)Very Low (Automatic link tracking)VBScript BaseScreenNameAny UI Object + VBS Action1 line of VBScriptFast (~20-50 ms)Low (Requires valid filename strings)VBScript PictureWindowAny UI Object + VBS ActionMulti-line VBScriptFast (~20-50 ms)Medium (Object name dependencies)C-Script (OpenPicture)Standard Button / Hotspot1 line of C-CodeInstantaneous (<10 ms)Low (Native WinCC C-API)PCS 7 Picture Tree ManagerPicture Tree HierarchyNone (Menu generation)InstantaneousLowest (Native APL navigation)

Verification

Confirm that screen navigation operates reliably in runtime:

  1. Open WinCC Explorer, activate OS Runtime, and navigate to the screen containing the static text.
  2. Open the WinCC GSC Diagnostics window (or launch apdiag.exe / Output Window for VBScript errors).
  3. Click the static text object.
  4. Confirm that the target screen CC1CC1.pdl loads immediately inside the picture window or main screen.
  5. Verify that no VBScript runtime errors appear in the GSC Diagnostics window.

Limitations and Operational Precautions

Review the following technical limitations when implementing custom navigation scripts:

  • Bypassing PCS 7 Picture Tree: Hardcoded screen changes bypass the PCS 7 standard Area Overview and Picture Tree Manager. When arbitrary screens are opened, the @Overview1 navigation bar may lose synchronization with the current plant area.
  • VBScript Single-Threaded Execution: In WinCC, VBScript executes on a single global thread per client session. Long-running loops or complex queries inside button clicks can freeze graphic responsiveness.
  • Case Sensitivity: Always ensure consistent lower-case .pdl extensions across scripts and file names on disk.

Engineer FAQ

Why use HMIRuntime.BaseScreenName instead of ScreenItems for full-screen changes?

HMIRuntime.BaseScreenName targets the top-level runtime container, replacing the entire root graphic. ScreenItems only targets child controls embedded within the currently open screen.

Can a standard button change pictures without any VBScript or C-code?

Yes. By dropping a standard Windows button onto the screen and running the Dynamic Wizard 'Picture Change' (Bildwechsel), WinCC automatically attaches pre-compiled C-code without requiring manual programming.

Where can I see VBScript runtime errors when a navigation click fails?

Insert an 'Application Window' control configured for 'Global Script Diagnostics' (GSC Diagnostics) onto a test screen, or launch the Siemens APDiag utility (apdiag.exe) from the WinCC bin folder.

Technical References

Related Articles

Related Tags

  • WinCC Graphics Designer
  • VBScript Navigation
  • Picture Window
  • Dynamic Wizard
  • BaseScreenName
  • PCS 7 OS
6 respuestas