Referencing Nested Picture Windows Across Hierarchy Levels in WinCC VBScript

Referencing Nested Picture Windows Across Hierarchy Levels in WinCC VBScript

To reference an object located inside deeply nested Picture Windows in SIMATIC PCS 7 OS using VBScript where HMIRuntime.ActiveScreen fails, address the control through the HMIRuntime.Screens hierarchical path syntax. In WinCC, nested picture windows are traversed using the syntax: HMIRuntime.Screens("RootScreen.Window1:ChildPic1.Window2:ChildPic2").ScreenItems("TargetObject"). For a control named 'PIC_HoraHora_1' residing in @logo.pdl inside picture window 'picturewindow1' of 'overview1.pdl' under root '@SCREEN', reference it via: HMIRuntime.Screens("@SCREEN.@win11:overview1.picturewindow1:@logo").ScreenItems("PIC_HoraHora_1").

Table of Contents

WinCC Graphics Object Hierarchy and Picture Window Nesting

In SIMATIC PCS 7 OS, the runtime visualization architecture organizes user screens inside hierarchical containers called Picture Windows (Bildfenster). The root container is @SCREEN.pdl, which hosts navigation banners, alarm headers, and the working area.

WinCC supports nesting Picture Windows up to 8 hierarchy levels deep. When a control (such as a WinCC TrendControl, AlarmControl, or gauge) is embedded inside a sub-picture (e.g. @logo.pdl), the control is encapsulated within the scope of its immediate parent container rather than the global desktop screen.

Why HMIRuntime.ActiveScreen Fails Across Nested Windows

Engineers developing automation scripts often employ HMIRuntime.ActiveScreen.ScreenItems("ObjectName"):

  • HMIRuntime.ActiveScreen resolves strictly to the picture file that currently holds desktop keyboard/mouse focus.
  • If a script executes from a button on @Overview1.pdl or a global action, ActiveScreen points to overview1.pdl.
  • Because the target TrendControl (PIC_HoraHora_1) resides inside @logo.pdl, the graphics engine cannot locate the object within overview1.pdl, generating a VBScript runtime exception (Object required: ScreenItems(...)).

Syntax Rules for HMIRuntime.Screens Addressing

WinCC requires a precise composite path string to navigate nested container boundaries:

  1. Root Screen: Specify the root screen name without file extension (@SCREEN).
  2. Dot Separator (.): Appends the first Picture Window object name (.@win11).
  3. Colon Separator (:): Appends the name of the picture currently loaded inside that window (:overview1).
  4. Recursive Child Windows: For each subsequent child window, append .ChildWindow:ChildPicture.
  5. ScreenItems Binding: Once the path to the target picture is fully resolved, call .ScreenItems("TargetObject").

Step-by-Step VBScript Implementation for CSV Trend Export

Follow this sample code to manipulate the trend control and trigger a CSV export from a top-level action:

Sub ExportTrendData()
    On Error Resume Next
    Dim objScreen, objTrend, startTime, endTime

    ' Resolve the nested path to @logo.pdl
    Set objScreen = HMIRuntime.Screens("@SCREEN.@win11:overview1.picturewindow1:@logo")
    If objScreen Is Nothing Then
        HMIRuntime.Trace "Error: Unable to locate target screen hierarchy." & vbCrLf
        Exit Sub
    End If

    Set objTrend = objScreen.ScreenItems("PIC_HoraHora_1")
    If Not objTrend Is Nothing Then
        startTime = DateAdd("n", -10, Now())
        endTime = Now()

        objTrend.TimeAxisRangeType = 1
        objTrend.Online = False
        objTrend.TimeAxisBeginTime = startTime
        objTrend.TimeAxisEndTime = endTime
        objTrend.Activate
        ' Execute CSV export method
        objTrend.Export "C:\Export\TrendData.csv"
    End If
End Sub

Addressing Syntax Comparison Across WinCC Scenarios

The table below details addressing syntax across different scripting contexts:

Context / LocationScript ApproachSyntax ExampleWhen to UseDirect Internal ScriptLocal ScreenItemsScreenItems("PIC_HoraHora_1")Script executes inside @logo.pdl itselfParent to Immediate ChildParent ScreenItemsScreenItems("picturewindow1").Screen.ScreenItems(...)Script executes on overview1.pdlAbsolute Hierarchy PathHMIRuntime.ScreensHMIRuntime.Screens("@SCREEN.@win11:overview1.picturewindow1:@logo")Global scripts / top-level buttonsRelative Upward NavigationParent TraversalItem.Parent.Parent.ScreenItems(...)Moving up container levels in C/VBSBase Screen ReplacementBaseScreenNameHMIRuntime.BaseScreenName = "NewPage.pdl"Replacing entire display workspace

Verification

Verify script execution and object referencing in runtime:

  1. Open WinCC GSC Diagnostics (apdiag.exe / Application Window for Global Script Diagnostics).
  2. Trigger the VBScript action from the operator interface.
  3. Verify that no VBScript runtime errors (e.g. error code 800A01A8 Object Required) appear in the diagnostics window.
  4. Check the file system; confirm the CSV export file is successfully generated with valid timestamped trend records.
  5. Verify that the trend control in @logo.pdl reflects the modified time axis boundaries.

Limitations and Operational Precautions

Observe the following safeguards when scripting nested picture windows:

  • Omit the .pdl Extension in Path Strings: In HMIRuntime.Screens, specify picture names without the .pdl extension (e.g. :overview1, not :overview1.pdl), as adding the extension causes path parsing failure.
  • Exact Casing Mandatory: WinCC internal string comparisons for picture windows and objects are case-sensitive. Ensure object names match Graphics Designer properties exactly.
  • Asynchronous Timing: If the target picture window is not loaded or has Visible = False, object referencing may fail; always include If Not objTrend Is Nothing error handling.

Engineer FAQ

Why must the .pdl extension be omitted in the HMIRuntime.Screens path string?

WinCC internal object model parses the picture name token up to the colon delimiter and automatically binds the picture database handle. Appending '.pdl' within the path causes string comparison mismatch.

Can I address an object inside a Picture Window if the window is currently invisible?

Yes, as long as the Picture Window has a picture assigned to its PictureName property and is loaded in runtime memory, VBScript can read and write its properties even if Visible = False.

What is the maximum nesting depth for Picture Windows in WinCC?

SIMATIC WinCC supports a maximum nesting depth of 8 levels of Picture Windows.

Technical References

Related Articles

Related Tags

  • WinCC VBScript
  • Picture Window
  • HMIRuntime.Screens
  • TrendControl Export
  • PCS 7 Graphics
  • ScreenItems
6 respuestas