show the entry list
WinCC (TIA Portal) -- Creating HMI configurations -- Working with system functions and Runtime scripting
With WinCC Runtime Professional, how do you read out and process the computer name of the Thin Client currently connected via the Terminal Server?
How do you configure a screen change via the controller in WinCC (TIA Portal)?
How do you access an SQL database in WinCC Runtime Advanced using a script?
Which VBS information and VBS programming aids are there in WinCC (TIA Portal)?
How can you start specific items in the Control Panel directly from the Runtime of a Comfort Panel?
How can you write data to a file or read data from a file by means of a script on a Comfort Panel with SIMATIC WinCC (TIA Portal)?
Tips and tricks for creating scripts in WinCC (TIA Portal)
How do you set the time display format (12 or 24 hours, for example) of the WinCC Online Trend Control in SIMATIC WinCC Professional?
How can you export and reimport WinCC Runtime data?
How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
Multi Panel -- Creating HMI configurations -- Tips and tricks for configuring
How can you write data to a file or read data from a file by means of a script on a Comfort Panel with SIMATIC WinCC (TIA Portal)?
How do you create a time switch with WinCC flexible?
How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
With which versions can you select the MP377 15" Touch daylight readable as operator panel?
How do you configure a connection between WinCC flexible Runtime (PC/Panel) and a SIMATIC S7-300/S7400 via PROFIBUS/MPI?
Creating underscore with the MP270
How can you start specific items in the Control Panel directly from the Runtime on an operator panel?
Touch Panel / Operator Panel -- Creating HMI configurations -- Tips and tricks for configuring
Which entries are available on the internet for migration to STEP 7 (TIA Portal) and WinCC (TIA Portal)?
How do you create a time switch with WinCC flexible?
How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
How do you configure a connection between WinCC flexible Runtime (PC/Panel) and a SIMATIC S7-300/S7400 via PROFIBUS/MPI?
How can you start specific items in the Control Panel directly from the Runtime on an operator panel?
How do you implement the "Clean Screen" function for cleaning the touch screen on Mobile Panels and OP 177B?
Button as pure illuminated indicator with a TP170A
Height of a textbox in a standard configuration (ProTool V6.0)
CPU functions for S7-300 with OP7/OP17
Picture change on the TP170A as tag function
"Tahoma" is the only font that can be used with OP/TP 170A/B and C7-635
How can you implement an OP73 as a handheld?
Mobile Panels -- Creating HMI configurations -- Tips and tricks for configuring
How do you use a script to determine whether a storage drive with removable media (USB stick, SD/MMC card) is ready for writing on an HMI device?
In WinCC (TIA Portal), how do you configure a connection between WinCC Runtime Advanced or HMI Panel and an S7 controller over Industrial Ethernet (PROFINET)?
How can you write data to a file or read data from a file by means of a script on a Comfort Panel with SIMATIC WinCC (TIA Portal)?
How do you create a time switch with WinCC flexible?
How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
How do you configure a connection between WinCC flexible Runtime (PC/Panel) and a SIMATIC S7-300/S7400 via PROFIBUS/MPI?
How can you start specific items in the Control Panel directly from the Runtime on an operator panel?
How do you implement the "Clean Screen" function for cleaning the touch screen on Mobile Panels and OP 177B?
"Clean Screen" function blocked with Mobile Panel 170
Evaluation of the handwheel position on the Mobile Panel 170
What should you pay attention to when configuring a project ID on the Mobile Panel 177 / 277 with battery pack?
Comfort Panels -- Creating HMI configurations -- Tips and tricks for configuring
How do you use a script to determine whether a storage drive with removable media (USB stick, SD/MMC card) is ready for writing on an HMI device?
In WinCC (TIA Portal), how do you configure a connection between WinCC Runtime Advanced or HMI Panel and an S7 controller over Industrial Ethernet (PROFINET)?
Why are configured graphics not displayed on the Comfort Panel?
How do you prevent the full screen mode of the screen keyboard when keying in on the SIMATIC HMI TP700 Comfort, TP900 Comfort or TP1200 Comfort Portrait?
What are the options for configuring a check box or radio box for SIMATIC WinCC (TIA Portal)?
How can you write data to a file or read data from a file by means of a script on a Comfort Panel with SIMATIC WinCC (TIA Portal)?
How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
Part number:

Description
Accessing object properties via a script serves as an alternative to configuring object properties from the Properties dialog box.
Some objects cannot be changed in SIMATIC WinCC (TIA Portal) using the available options, resizing rectangles in runtime, for example. These attributes or properties can be changed or dynamized with the aid of scripts.

At the end of the entry is a PDF document and the described sample project ready for downloading.
The PDF document contains a list of objects included by default in WinCC Comfort and WinCC Advanced. In addition, all the properties (attributes) of the objects and the type of access to the properties are listed which can be called using a script statement. 

Instructions
In the example below we show how you can change the width and height of a rectangle using a script in Runtime.

The names used for the tags and the objects can be changed separately as required.
The tags do not need a controller connection (only if you want to assign the width and height of the rectangle via the controller).

For better understanding it is useful to open the attached configuration.
 
No. Procedure
1 Add a rectangle
  • Insert an object of the "Rectangle" type into the "Screen_01" screen.
    Note
    The name of the screen will be used later in the script.
  • Define the size and name of the object.
    In this example the rectangle has a width of 100 and a height of 50.
    The name of the object is "Rectangle_1".
    Note
    The name of the object (rectangle) will be used later in the script.


Fig. 01

2 Create tags
The width and height of the rectangle are to be changed using a script. Create two internal tags named "RectangleHeight" and "RectangleWidth".
(Project navigation > Operator panel > HMI tags > Standard tag table).

The tags are assigned a start value. In this case, "100" for the width and "50" for the height (Properties > Values > Start value. The reason for this measure is described further here (Link).

Note
The tags will be used later in the script.


Fig. 02

3 Create scripts
Two scripts are used in the configuration.
(Project navigation > Operator panel > VB scripts > Add new VB function).
You can specify the names of the scripts as required.
In this example:
  • Script_01_Rectangle
  • Script_02_Init_Rectangle

Below we describe the two scripts used in more detail.

4 Script_01_Rectangle
Using the "Script_01_Rectangle" script you can change the size of the rectangle.

Create an internal script tag
You need an internal script tag to change the properties of an object in WinCC (in this case the properties of a rectangle).
You can specify the name of the tag as required.
In this example: "ObjectRectangle" 

Define the object
The "Rectangle_1" object is transferred in the script editor to the "ObjectRectangle" internal tag.
The "HmiRuntime.Screens" statement indicates the screen where the object (rectangle) is located.
The object (rectangle) in the screen in question is accessed explicitly using the "ScreenItems" statement.
In this example:
Set ObjectRectangle = HmiRuntime.Screens("Screen_01").ScreenItems("Rectangle_1"),

Note
Bear in mind that the object must be unique in that screen, this means that the name may not be used by any other object.
However, the same object name may exist in other screens!

Assign to the object (rectangle) the tags for "Height" and "Width"
The "Width" defines the object's width.
The "Height" attribute defines the object's height.
Two tags for "Width" and "Height" have been defined for the rectangle used.
These tags are assigned to the object accordingly.

In this example:
ObjectRectangle.Width = SmartTags("RectangleWidth")
ObjectRectangle.Height = SmartTags("RectangleHeight")


Fig. 03

5 Script_02_Init_Rectangle
Using the "Script_02_Init_Rectangle" script you can change the size of the rectangle to a size defined in the script (reset to "initial size").
It is only for resetting the rectangle to the "original size", for example, without having to enter a value beforehand using the IO fields.

The script has exactly the same structure as the "Script_01_Rectangle" script. The only difference is that fixed values are given for the width ("200") and height ("100") of the rectangle.

 
Fig. 04

6 Tips for creating the script

Autocomplete

  • Use "Autocomplete" when creating scripts.
    Autocomplete is a feature that provides a context-dependent list in a dialog from which you can choose the tags or statements required.
    Example 1
    Enter a "period" after the "...= HmiRuntime" dialog.
    A "pop-menu" opens from which you can select from all of the available tags and statements.


Fig. 05

Example 2
Enter a "period" after the "ObjectRectangle" dialog.
A "pop-menu" opens from which you can select from all of the available attributes.


Fig. 06

Add tag

  • Go to the point where you want to add the tag.
  • Right-click. A pop-up menu opens.
    Select the menu command "Autocomplete > List objects".
    Another window opens from which you can select the relevant tag and accept it with the symbolic "OK" button.


Fig. 07

7 Add buttons and IO fields
To specify the width and height of the rectangle you need two IO fields. Two buttons are used to run the scripts.
  • "Change size" ("Script_01_Rectangle" script)
  • "Standard size" ("Script_02_Init_Rectangle" script)


Fig. 08

The internal tags for "width" and "height" are configured respectively at the IO fields
(Properties > General > Process).

The "Change size" button calls the "Script_01_Rectangle" script
(Properties > Events > Click).

The "Standard size" button calls the "Script_02_Init_Rectangle" script
(Properties > Events > Click).

8 Define properties of the "Screen_01" screen
The this example is executed using the "Screen_01" screen.

If the size of the rectangle is changed, then this is only present temporarily. If the page is called again, the rectangle resumes the size of the configuration.

If you wish to retain the changed size after a page change, call the "Script_1_Rectangle" script when the "Screen_01" screen is loaded (Properties > Events > Loaded).

The first time the page is called or if no values have been defined yet for the size of the rectangle, then the rectangle is not visible on the page (width and height have the value "Zero").
This can be prevented by defining initial values at the "Width" and "Height" tags (Link).


Fig. 09

9 Notes and tips on configuring
  • To test the attached configuration you can use a TP1200 Comfort or the simulation from WinCC Comfort or WinCC Advanced. 
  • If you specify a value via the IO fields, then make sure that with this value the current screen width or screen height is not exceeded by the object (rectangle). Otherwise you get a system message (script error).
    Remedy
    In the properties of the "RectangleHeight" and "RectangleWidth" tags you can set a maximum value via "Properties > Range > Settings". This value depends on the position of the object configured.
  • Error in the script ...
    The scripts read out the name of the object (rectangle). If you want to test the configuration in the "PC Runtime Simulation", then before starting Runtime check that the option is enabled under "Runtime Settings > General > Screen > Load name".
  • The Help system of WinCC (TIA Portal) provides more information about the topic of "VBS object model" (see figure below).


Fig. 10 

Table 01

Additional Information (not relevant for this example)
The Help system of WinCC V11 (TIA Portal) provides all the objects in relation to VBS. The designations for the various objects are listed in the table below.

For example, enter "Rectangle" as search term in the index of the information system. As a result you get an overview of the object from which you can then call additional information.


Fig. 11 

Basic objects
 

No.

Object HMI Runtime Object
1 Line Line
2 Polyline Polyline
3 Polygon Polygon
4 Ellipse Ellipse
5 Circle Circle
6 Rectangle Rectangle
7 Text field TextField
8 Graphics display GraphicView
Table 02

Elements
 

No.

Object HMI Runtime Object
1 IO field IOField
2 Button Button
3 Symbolic IO field SymbolicIOField
4 Graphical IO field GraphicIOField
5 Date/time field DateTimeField
6 Bar Bar
7 Switch Switch
8 Symbol library SymbolLibrary
9 Slider Slider
10 Pointer instrument Gauge
11 Clock Clock
Table 03

Controls
 
No. Object HMI Runtime Object
1 Alarm View MessageView
2 Trend view TrendView
3 User Display UserView
4 Status/Control StatusForce
5 Sm@rtClient display SmartClientView
6 Recipe display RecipeView
7 f(x) trend display f(x)TrendView
8 System diagnostics display SystemDiagnosticsView
9 Media player MediaPlayer
Table 04

Note
Bear in mind that not all objects are available in all operator panels.

Creation environment
The screens and downloads in this FAQ were created with WinCC V11.

Downloads
 
Contents of the downloads

Download

Documentation 
Attachment 1 contains a list of objects included by default in WinCC Comfort
and WinCC Advanced. In addition, all the properties (attributes) of the objects and the type of access to the properties are listed which can be called via the script statement of "HmiRuntime.Screens" and "ScreenItems". 

Object_Attributes ( 40 KB )
Code 
The packed file contains the sample project described.

TIA_Project_V11
( 2314 KB )

 Entry ID:53752382   Date:2012-03-27 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Topics
Help
Online Help
Guided Tour