Hello Everybody.
I was wondering if it would be possible to construct a Tag’s source path (e.g. an OPC Tag’s path) by using a combination of strings and dynamic Values from other tags.
For instance, I have two UDT instances called Plc , stored in the Device1 and Device2 folder respectively, like so:
MyTags/Devices/Device1 /Plc/DeviceName
MyTags/Devices/Device2 /Plc/DeviceName
The Plc UDT contains a tag called PlcDeviceName.
Now, each PLC contains a software module called ModuleA, which I model like so:
MyTags/Devices/Device1/Modules /Cooker/Pressure
MyTags/Devices/Device2/Modules /Cooker/Pressure
In both cases, Cooker are instances of a UDT called Cooker , which contains an OPC Tag called Pressure .
What I’m trying to do is to define a dynamic OPC path for Pressure , like so:
[{[.]…/…/Plc/DeviceName}]DB100,I8
which references integer 8 within data block 100 of the underlying SIEMENS PLC (Device1 or Device2 respectively).
I understand the above syntax doesn’t work; I just used it to illustrate my question with an example.
My questions in short:
Is it possible to define dynamic OPC paths?
If so, how?
If not directly possible, can we use some advanced scripting technique to achieve the same results?
Thanks.
Here’s an update of what I’ve been able to accomplish so far.
Based on the following example, this is the result:
I’ve been able to construct a script string by referencing other tags, using the relative tag path, like so:
OpcItemPath Expression Tag’s expression:
"[" + tag('[.]../../Plc/DeviceName') + "]" + "DB733,I8"
Script Expression Tag’s expression:
"shared.pcsmis.opc.readValue('" + tag('[.]OpcItemPath') + "')"
The returned string stored in the “Script” tag is:
shared.pcsmis.opc.readValue('[S1P01]DB733,I8')
This is the global script that returns the OPC value, and it works great as I tested it on its own:
def getOpcServerName():
return 'Ignition OPC-UA Server'
def readValue(item_path):
return system.opc.readValue(getOpcServerName(), item_path)
The only problem I still have is, how to run the script successfully from the Pressure Expression Tag.
Pressure Expression Tag’s expression:
runScript( toString( tag('[.]Script') ) )
This is the error displayed under Tag Diagnostics:
Anyone knows what this error means?
Thanks.
Hello, did you found a solution for this, i'm looking for something simular?
pturmel
October 12, 2026, 12:55pm
4
You should start a new post and share exactly what you are trying to do, what you have tried, and precise results so far.
@Frank_Pockele As you may have noticed, I haven't looked at this in a while
Please message me here to let me know if you are starting a new post to find an answer to this problem. Believe it or not, I'm still interested in finding an answer.
Cheers