OpennessScripter Intro DOC V116 en
OpennessScripter Intro DOC V116 en
Introduction
Siemens
TIA Portal / Openness API Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109742322 Support
Legal information
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG ("Siemens"). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2021 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples, you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 2
Table of Contents
Table of Contents
Legal information ......................................................................................................... 2
1 Introduction ........................................................................................................ 4
1.1 The TIA Portal programming interface ................................................. 4
1.2 Application examples ........................................................................... 4
1.3 Until now: Creation of own applications ............................................... 5
1.4 New: Create scripts with OpennessScripter ......................................... 6
1.5 Advantages .......................................................................................... 6
2 Requirements ..................................................................................................... 7
2.1 Required know-how.............................................................................. 7
2.2 System requirements ........................................................................... 7
2.3 Enabler file and usage file .................................................................... 7
3 Installation .......................................................................................................... 8
4 The first start ...................................................................................................... 9
4.1 Structure of the start screen ................................................................. 9
4.2 Structure of the editor ......................................................................... 10
4.3 Creating a script ................................................................................. 11
4.3.1 General ............................................................................................... 11
4.3.2 "Hello World" script ............................................................................. 12
4.3.3 "Open TIA Portal" script ..................................................................... 12
© Siemens AG 2021 All rights reserved
5 Examples .......................................................................................................... 13
5.1 Generating a project ........................................................................... 13
5.2 Updating a project .............................................................................. 14
6 Appendix .......................................................................................................... 15
6.1 Service and support ........................................................................... 15
6.2 Links and literature ............................................................................. 16
6.3 Change documentation ...................................................................... 16
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 3
1 Introduction
1 Introduction
This introduction gives you a brief insight into the OpennessScripter.
NOTE The detailed documentation including the command set can be found in the
OpennessScripter menu "Help".
Note Using the interfaces incorrectly can result in loss of data and production
downtime.
© Siemens AG 2021 All rights reserved
NOTE Further ready-to-use application examples, partly including source code for own
adaptations, can be found on the Siemens Industry Online-Support topic
page "TIA Portal Openness" \5\.
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 4
1 Introduction
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 5
1 Introduction
Instead of programming commands, you use a meta language. This reduces the
writing work. In the example shown in Figure 1-2, this results in saving of about
© Siemens AG 2021 All rights reserved
95 % of the pure programming work. This example does not yet include other
savings such as incorporation into the high-level language.
1.5 Advantages
Using the OpennessScripter provides several advantages over an in-house
development.
Table 1-2
Characteristic Evaluation
Functionality The OpennessScripter provides only the basic functionality of the
TIA Portal Openness API.
Reliability When writing a script, the number of potential errors caused by the
user is significantly reduced.
Usability An elegant user interface and commands that are oriented towards
English make the OpennessScripter easier.
Efficiency No differences regarding execution time.
(performance)
Changeability Customizing scripts is considerably easier and quicker than
modifying an application developed in a high-level language.
Portability Scripts are text files and can be transferred more easily. A special
development environment is not necessary.
NOTE Portal Openness in combination with high-level languages (C#, VB.NET) offers
far more possibilities than this application example "OpennessScripter".
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 6
2 Requirements
2 Requirements
2.1 Required know-how
• TIA Portal user knowledge (beginner’s level)
• No programming skills
NOTE Please install all available TIA Portal Service Packs and updates.
NOTE Importing blocks and user data types into a PLC device requires the "Enabler-
File" and "Usage-File" license files only for TIA Openness Versions < V14
SP1.
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 7
3 Installation
3 Installation
Setup
A setup is provided for the OpennessScripter. It allows you to install the software
on the computer.
In the start menu, a shortcut is created in "Programs > Siemens Automation >
OpennessScripter".
During the installation process, you should select the following options:
1. Enter the current Windows user in the local "Siemens TIA Openness" Windows
group.
2. Add the application to the TIA Portal Openness whitelist.
3. Perform a system check to check the TIA Portal dependencies.
Uninstalling
You can use Control Panel > "Programs and Features" > "OpennessScripter" to
uninstall the software.
Sequence
You can install the OpennessScripter, even if TIA Portal and the Openness option
package are not installed on your system.
In this case, you can write scripts but not run them.
If you install TIA Portal or the Openness option package later, you must manually
perform the above steps 1. and 2. or reinstall the OpennessScripter.
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 8
4 The first start
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 9
4 The first start
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 10
4 The first start
4.3.1 General
Rules
There are three rules for the script commands:
• Each command is in a separate line.
• A comment starts with a "#" and can be at both the start and end of a line.
• Upper/lower-case letters or indenting commands do not affect the script’s
functionality.
Command types
The following types of commands exist:
• Command with optional parameters
• Command without parameters
• Hybrids of these two types (for commands with multiple parameters).
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 11
4 The first start
Follow the below instructions to write a script that outputs the text "Hello World".
1. Start the OpennessScripter and click the "Empty script" template. Delete the
entire default text in the Editor so that the text field is blank. Write the following
new line:
print "Hello World!"
2. In the "Run" menu, click the "Run" option to start the script. Keep an eye on the
below "Output" window. It displays the output text "Hello World!"
3. You have successfully completed your Hello World script. In the "File" menu,
click the "Close" option to return to the start screen.
Follow the below instructions to write a script that opens TIA Portal.
1. Start the OpennessScripter and click the "Empty script" template.
2. The template already contains texts that start with a diamond "#". These texts
are comments for your own documentation. Add your name and a description,
for example "My first script", to the comment:
# Description: My first script
Go to the end of the script and write a new line. Make sure not to enter a
diamond "#":
© Siemens AG 2021 All rights reserved
open Portal
Insert a line break at the end of the line and write the next line:
disconnect Portal
3. In the "Run" menu, click the "Check" option to check the script for errors. Read
the information in the output. If the error check finds errors in your script,
correct them.
4. In the "File" menu, click the "Save" option to save the script on your computer.
The file gets the ".opns" extension.
5. In the "Run" menu, click the "Run" option to start the script. An animated
progress bar at the bottom left indicates that the script is currently being
executed. No changes are possible during execution. In the OpennessScripter,
the specific line that is currently being executed is indicated in color to the left
of the line number.
6. The script starts TIA Portal. Depending on the computing power, this step may
take some time. The script disconnects from TIA Portal. Please note: This does
not terminate TIA Portal. You cannot close the TIA Portal user interface
automatically. As soon as the script is done, the status displayed in the bottom
left part of the OpennessScripter has returned to "Ready".
7. You have successfully written your first script. In the "File" menu, click the
"Close" option to return to the start screen.
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 12
5 Examples
5 Examples
5.1 Generating a project
Scenario
After production planning and before engineering: A machine manufacturer
produces a series of machines. The manufacturer can use the OpennessScripter
as a product configurator and generate projects on an automated basis.
Steps
The individual steps are as follows:
1. Start TIA Portal and open a project
2. Select a controller
3. Create a group for a tag table
4. Import a single tag table
5. Import several program blocks
6. Compile the controller
7. Save and close the project
8. Finally disconnect from TIA Portal
© Siemens AG 2021 All rights reserved
Script
The commands for the script are as follows:
# Start TIA Portal and open project
open Portal
open Project "D:\Projects\AssemblyLine\AssemblyLine.ap17"
# Select controller
select Plc "PLC_1"
# Compile controller
compile Plc SoftAndHardware
# Disconnect
disconnect Portal
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 13
5 Examples
Steps
The individual steps are as follows:
1. Connect to an already open project in TIA Portal
2. Open a global library
3. Select a controller
4. Update the controller using the global library
5. Close the global library
6. Save the project
7. Finally disconnect from TIA Portal
Script
The commands for the script are as follows:
# Reuse an already opened TIA Portal project
connect Portal "D:\Projects\AssemblyLine\AssemblyLine.ap17"
© Siemens AG 2021 All rights reserved
# Open library
open GlobalLibrary "D:\Libraries\LGF\LGF.al17"
# Close library
close GlobalLibrary
# Save project
save Project
# Disconnect
disconnect Portal
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 14
6 Appendix
6 Appendix
6.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
support.industry.siemens.com
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts.
Please send queries to Technical Support via Web form:
siemens.com/SupportRequest
© Siemens AG 2021 All rights reserved
Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
support.industry.siemens.com/cs/sc
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 15
6 Appendix
V1.1.0 09/2016 • System requirements: License files for user data types
• Settings "Local users and groups"
• Figure: Editor
• Figure: Hello World script
• Examples
• Installation
• System requirements: .NET Framework 4.6.1
V1.1.1 01/2017 • Entry ID
• Chapter on enabler file and usage file
• Uninstalling and installation order
V1.1.2 02/2017 • Examples for TIA Portal V14
04/2017 • Revision of the document
05/2017 • Support for TIA Portal V14 SP1 and V13 SP2 and
notes
06/2017 • Copyediting and translation
V1.1.3 01/2018 • Support for TIA Portal V15 and notes
V1.1.4 10/2018 • Support for TIA Portal V15.1 and notes
V1.1.5 02/2020 • Support for TIA Portal V16 and notes
V1.1.6 11/2021 • Support for TIA Portal V17 and notes
• System requirements: .NET Framework 4.8
• Notes for working with projects (chapter 4.3)
• Revision of the examples (chapter 5)
OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 16