Documente Academic
Documente Profesional
Documente Cultură
com)
Home
(start)
Product
Support
(5)
Avaliar
How do you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?
Post
Accessing object properties via a script serves as an alternative to configuring object properties from the Properties dialog box.
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, there is a list of all the properties (attributes) of the objects and the type of access to the properties which
can be called using a script statement.
All the properties and methods of an object which can be dynamized are available in the manual under "Visualize
processes > Working with system functions and Runtime scripting > Reference > VB Scripting > VBS Object Model"
in the sections entitled "Properties
(https://support.industry.siemens.com/cs/ww/en/view/109091876/37924158731)" und "Methods
(https://support.industry.siemens.com/cs/ww/en/view/109091876/37924261003)".
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. For this you create two internal tags
named "RectangleHeight" and "RectangleWidth".
(Project navigation > Operator panel > HMI tags > Default 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 on (see Step 8).
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 functions").
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.
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 attributes and tags for "Height" and "Width" .
The "Width" attribute 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
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
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
Fig. 09
Fig. 10
Table 01
Fig. 11
Siemens AG 2009-2016 -
Note
Bear in mind that not all objects are available in all operator panels.
Downloads
Documentation
Attachment 1 contains a list of objects included by default in WinCC Comfort
and WinCC Advanced. In addition, there is a list of the properties (attributes) of the objects and the type of
access to the properties which can be called via the script statement of "HmiRuntime.Screens" and
"ScreenItems".
53752382_object_attributes_en.pdf (125.2 KB)
(/cs/attachments/53752382/53752382_object_attributes_en.pdf)
Code
The packed file contains the described sample project in the version SIMATIC WinCC (TIA Portal) V13 SP1.
Avaliar post
nenhuma avaliao
Avaliar
Enviar
*) Aviso Atravs da funo feedback no possvel pedir informaes tcnicas. Por favor, utilize para isto o Support Request (/my/br/pt/requests/#createRequest).
Siemens AG 2009-2016 -