Siemens.Collaboration.Net.TiaPortal.Openness.Extensions
21.0.1765368043
Prefix Reserved
dotnet add package Siemens.Collaboration.Net.TiaPortal.Openness.Extensions --version 21.0.1765368043
NuGet\Install-Package Siemens.Collaboration.Net.TiaPortal.Openness.Extensions -Version 21.0.1765368043
<PackageReference Include="Siemens.Collaboration.Net.TiaPortal.Openness.Extensions" Version="21.0.1765368043" />
<PackageVersion Include="Siemens.Collaboration.Net.TiaPortal.Openness.Extensions" Version="21.0.1765368043" />
<PackageReference Include="Siemens.Collaboration.Net.TiaPortal.Openness.Extensions" />
paket add Siemens.Collaboration.Net.TiaPortal.Openness.Extensions --version 21.0.1765368043
#r "nuget: Siemens.Collaboration.Net.TiaPortal.Openness.Extensions, 21.0.1765368043"
#:package Siemens.Collaboration.Net.TiaPortal.Openness.Extensions@21.0.1765368043
#addin nuget:?package=Siemens.Collaboration.Net.TiaPortal.Openness.Extensions&version=21.0.1765368043
#tool nuget:?package=Siemens.Collaboration.Net.TiaPortal.Openness.Extensions&version=21.0.1765368043
TIA Portal Openness Extensions
Siemens Collaboration Openness Extensions provide extensions for Siemens Engineering types to help you write cleaner and more efficient code.
[!WARNING] Important Compatibility Notice
TIA Portal Openness Extensions V21 are only compatible with TIA Portal V21 and above.
TIA Portal V21 introduces breaking changes in the Openness API. Applications built against TIA Portal versions below V21 are not compatible with V21 and above.
Installation
- install package
Siemens.Collaboration.Net.TiaPortal.Openness.Extensionsand select a matching version (20.* = TIA Portal V20, 21.* = TIA Portal V21) - reload and build the project
Dependencies
By installing this package, the following packages are automatically installed and must not be installed individually:
TIA Portal Openness References
All Siemens.Engineering assemblies are referenced automatically. Please see README for further documentation.TIA Portal Openness Resolver
UsingApi.Global.Openness().Initialize()will resolve all Siemens.Engineering assemblies at runtime. Please see README for further documentation.
Extensions
TIA Portal Openness Extensions provide a lot of extensions for various Siemens Engineering types. The following chapters are an excerpt of the most frequently used extensions.
Hardware
Get all Device in a project (iterates through devices, device groups and ungrouped devices recursively)
IEnumerable<Device> devices = tiaProject.AllDevices()
Recursively get all DeviceItem of a Device
IEnumerable<DeviceItem> deviceItems = myDevice.AllDeviceItems()
Get all PlcSoftware instances in a project recursively
IEnumerable<PlcSoftware> plcSoftwares = tiaProject.AllPlcSoftwares()
Get all Startdrive devices in a project recursively
IEnumerable<Device> drives = tiaProject.AllStartdriveDevices()
Get all HMI devices (Advanced/Professional/Unified) in a project recursively
IEnumerable<Device> hmiDevices = tiaProject.AllHmiDevices()
Get all IO addresses used in an IoSystem
var addresses = ioSystem.GetIoAddresses();
Get all devices, containing device items with addresses in an IoSystem
IEnumerable<(Device Device, IEnumerable<(DeviceItem DeviceItem, IEnumerable<Address> Addresses)> deviceInfos = ioSystem.GetIoAddressInfos();
Software
If the given device is known to be a PLC, get the PlcSoftware of the device
PlcSoftware plcSoftware = device.AsPlc();
Get all blocks recursively
IEnumerable<PlcBlock> blocks = plcSoftware.BlockGroup.AllBlocks();
Parents
Get all parents of an IEngineeringObject
IEnumerable<IEngineeringObject> parents = engineeringObject.Parents();
Get first parent of type Device of an IEngineeringObject
Device device = engineeringObject.Parent<Device>();
Get TiaPortal instance
TiaPortal tiaPortal = engineeringObject.TiaPortalInstance();
Attributes
Get an attribute with type
string name = deviceItem.tAttribute<string>("Name"))
if (name is null)
logger.Error("Attribute not found");
Try set an attribute
if (deviceItem.TrySetAttribute("Name", "My Device Item"))
logger.Information("Name was set");
else
logger.Error("Unable to set name of the device");
Try get an attribute
if (deviceItem.TryGetAttribute("Name", out var name))
logger.Information($"The name is: {name}");
else
logger.Error("Unable to read name of the device");
Transfer attributes from one device to another device
// get attribute infos of all attributes
var sourceAttributeInfo = deviceA.GetAllAttributeInfos(tiaPortal, accessMode, null, excludeTypes)
// change the target
var targetObjectAttributeInfo = sourceAttributeInfo.Copy(targetDevice)
// apply values
targetObjectAttributeInfo.ApplyValuesFrom(sourceAttributeInfo)
WinCC
Unified
Get all HmiSoftware in this project recursively
IEnumerable<HmiSoftware> hmiSoftware = tiaProject.AllHmiSoftwares()
Get the HmiSoftware of a Device
HmiSoftware hmiSoftware = device.AsHmiSoftware();
Get the Device of a HmiSoftware
Device device = hmiSoftware.Device();
Get a screen by name or create it if not found
Screen conveyorsScreen = screens.AddOrGet("Conveyors");
Get a screen item by name or create it if not found
HmiSlider velocitySlider = screen.ScreenItems.AddOrGet<HmiSlider>("TargetVelocity");
Return the parent composition of a screen object
HmiScreenComposition screens = screen.ParentComposition();
Type safe access to all items of a specific type in a given screen
var textBoxes = screen.ScreenItems.Typed<HmiTextBox>();
Get all buttons
var buttons = screen.Buttons();
Get all sliders
var sliders = screen.Sliders();
Get all alarm controls
var alarmControls = screen.AlarmControls();
Advanced/Professional
Get all HmiTarget in this project recursively
IEnumerable<HmiTarget> hmiTargets = tiaProject.AllHmiTargets()
Get the HmiTarget of a Device
HmiTarget hmiTarget = device.AsHmiTarget();
Get the Device of a HmiTarget
Device device = hmiTarget.Device();
Add-Ins
Messages and Dialogs
Open message box in foreground
var result = AddInMessageBox.Show("Successfully imported all files", "Import done", MessageBoxButton.OK, MessageBoxImage.Information);
Open dialog in foreground
var result = myDialog.ShowDialogInForeground();
Context Menu Item
Catch an exception before an add-in is crashing and handle it in a handler
protected override void BuildContextMenuItems(ContextMenuAddInRoot addInRootSubmenu)
{
addInRootSubmenu.Items.AddActionItem<IEngineeringObject>("Item 1", ClickDelegate, UpdateStatusDelegate, OnError);
}
/// <summary>
/// Handle errors
/// </summary>
/// <param name="exception">Unhandled exception when executing add-in</param>
private void OnError(Exception exception)
{
// Show error message
AddInMessageBox.Show(exception.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
// Write error to file
//File.WriteAllText("...", exception.ToString());
}
Misc
Serialize path to engineering object to string
string engineeringObjectPath = engineeringObject.GetPath();
Deserialize path of engineering object to engineering object
IEngineeringObject engineeringObject = engineeringObjectPath.ToEngineeringObject();
Device device = devicePath.ToEngineeringObject<Device>();
Get the version of specified product (default "TIA Portal Openness")
Version opennessVersion = tiaPortal.Version(); // 17.0.1.5 = V17 Service Pack 1 Update 5
Version startdriveVersion = tiaPortal.Version("SINAMICS Startdrive Advanced"); // 17.0.0.2 = V17 Update 2
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Siemens.Collaboration.Net.DuckTyping (>= 1.1.1725480204)
- Siemens.Collaboration.Net.NotifyModel (>= 3.0.1725521661)
- Siemens.Collaboration.Net.TiaPortal.Openness.Resolver (>= 2.0.1765367256)
- Siemens.Collaboration.Net.TiaPortal.Packages.Openness (>= 21.0.1765273298)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Siemens.Collaboration.Net.TiaPortal.Openness.Extensions:
| Package | Downloads |
|---|---|
|
Siemens.Collaboration.Net.TiaPortal.Openness.Startdrive.Extensions
Provides extension methods for SINAMICS Startdrive V21 openness development |
|
|
Siemens.Collaboration.Net.TiaPortal.Openness.Hmi.Extensions
Provides extension methods for TIA Portal V20 openness development |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 21.0.1765368043 | 412 | 12/12/2025 |
| 20.0.1744193700 | 1,048 | 4/11/2025 |
| 19.0.1725480561 | 1,016 | 9/6/2024 |
| 18.0.1725480533 | 385 | 9/6/2024 |
| 18.0.1685432504 | 993 | 5/30/2023 |
| 17.0.1725480504 | 285 | 9/6/2024 |
| 17.0.1685432473 | 402 | 5/30/2023 |
| 17.0.1685386061 | 745 | 5/29/2023 |
| 16.0.1725480456 | 255 | 9/6/2024 |
| 16.0.1685432419 | 308 | 5/30/2023 |