TIA Portal Openness

API for automation of engineering workflows

Requirements

  1. System Manual (as of 2023)

  2. ILSpy (for looking through the functions of the api inside Siemens.Engineering.dll)

  3. Install pythonnet from pip

import clr
from System.IO import DirectoryInfo, FileInfo

clr.AddReference('C:\\Program Files\\Siemens\\Automation\\Portal V18\\Bin\\PublicAPI\\Siemens.Engineering.Contract.dll') (1)
clr.AddReference(r"C:/Program Files/Siemens/Automation/Portal V18/PublicAPI/V18/Siemens.Engineering.dll") (2)

import Siemens.Engineering
import Siemens.Engineering.Compiler
import Siemens.Engineering.HW.Features
1 Needed for avoiding issues when importing the DLL file in Jupyter Notebooks
2 Needed for importing Siemens.Engineering modules

Check the notes for the API here.

FileNotFoundException: Could not load file or assembly or one of its dependencies.
FileNotFoundException: Could not load file or assembly 'Siemens.Engineering.Contract, Version=1800.100.4201.1, Culture=neutral, PublicKeyToken=37a18b206f7724a6' or one of its dependencies. The system cannot find the file specified.

To fix this error, simply add a reference DLL: Siemens.Engineering.Contract.dll

For example

clr.AddReference('C:\\Program Files\\Siemens\\Automation\\Portal V18\\Bin\\PublicAPI\\Siemens.Engineering.Contract.dll')

How To

Insert Function Block into a Network of Organization Block (aka Instance)

There’s no direct method but there’s a way through doing it in XML by exporting the Function Blocks [1].