Access UDT parameter in script’[default]VetctorTag/Vector/X’) should work.

I usually use the browsers, such as a Perspective binding, to figure out the syntax first.


Thanks for your info, the way works for the memory tags, but doesn’t work for OPC UDT tags.

The “[default]VetctorTag/Vector” is a OPC UDT tag that I dragged from a third part OPC UA server. Its whole data of X, Y, Z can be get by the with’[default]VetctorTag/Vector/X’) ,
but using’[default]VetctorTag/Vector/X’) doesn’t work for reading its struct member X.

What about this post?

Thanks for your info, I knew we could use JsonGet to retrieve Json format UDT of OPC tag.

Just want to know if it is possible to use to achieve this goal in script, because the jsonGet() function is only used in expression and it can’t be used in script.

If it provide the jsonGet() function in script, then it solve my issues.

What about this:

or this:

value ="New Tag3").value
value = system.util.jsonDecode(value)
print value
print value['X']
print value['Y']
print value['Z']

This post explain it…
EDIT: I just realized that @Kevin.Herron already explained this to you 11 days ago…?

Thanks for your comments.
I’ve try with your suggestion, it only works without the calling the eval() function as shown in the green box of below snapshot.
If we use eval() function or system.util.jsonDecode() function, both of them can’t parse the “Document” datatype, which is in fact printed as
<type ‘com.inductiveautomation.ignition.common.script.adapters.PyDocumentObjectAdaper’> as shown in below snapshot.

It seems that the Document type can’t be parsed by jsonDecode() function.
BTW, in fact, I’ve asked the question for document type UDT parsing as you mentioned, the jsonDecode() function also doesn’t work for that case, I use another workaround by using tags directly in script to solve my problem in that thread.

Well... then I'm 'lost'...
In my case, when I drag from OPC browser the UDT (struct) tag from my S7-1500 OPC UA server, that tag is Unicode string type (JSON). You obviously get Document type.

I'm using v7.9.12. You're using v8.
In v8 is deprecated (but it'll still work, for backward compatibility). The new function is system.tag.readAsync.
Maybe was changed in v8...??? Maybe @Kevin.Herron can explain?

EDIT: I read the other post it again and it seems that, because tag system is completely changed in v8: is fine but its most direct replacement in 8.0 is system.tag.readBlocking.

@dawei.liu if you’re getting a document type just call str() on it first.

1 Like

Yes, my bad... :flushed:
Anyway, good call on str()... :+1:

@Kevin.Herron and @zxcslo

Really appreciate your help, the str() works well and solve my issues

I understood the question incorrectly, but it is very interesting to see how to read a struct up and then access it’s members.

How would you write back to one member of the struct then?

Just as Kevin’s suggestion in jsonSet workaround in script

I just tested that it’s possible to write back the struct value through script (Ignition version 8.0.4 Nightly)

With below script, the UDT member ‘param1’ of ‘OPC_tag’ can be updated and writen back to OPCUA server.

value1 =‘OPC_tag’).value
value1 = system.util.jsonDecode(str(value1))
value1[‘param1’] = ‘updated_param1_value’
value2 = system.util.jsonEncode(value1)
system.tag.write(‘OPC_tag’, value2)

Doesn’t that write the whole structure back? Less than optimal.

It does, and it’s required because his tag represents the whole structure. Reading the whole structure is the only way to get decent performance out of built-in OPC UA servers like the one on the S7-1500.

It would be ideal if the client could magically derive the NodeId for any given structure member and write to just that Node in the server, but it’s not even a given that a server exposes the members as individual Nodes.

A job for a derived tag, perhaps, if the member node ID is available? Basically a different write path.

Regarding this,

I have a UDT instance called T103 (basically I have them from T101 to T120) and under UDT members are as follows:

I tried this approch, reading T103.value in tagPath and later used tagPath=system.util.jsonDecode(str(tagPath)). However when I print this, I get blank dictionary. hence tagPath.keys() doesn’t work either. Am I doing something wrong here?

Also tried eval() instead of jsonDecode its the same {} output. Thanks in advance


This thread is specifically about reading structured values over OPC from the built-in Siemens server. I can’t tell from the information you’ve provided if that’s what you’re trying to do or if you should be starting a new topic with more details.

Hi Kevin,

No I was trying to read a Memory parameter (which will later be converted into OPC) present inside UDT.

I came across this thread while considering the same question but on v8.1.35. though I'd add some v8.1 relevant detail.

One oddity I observed is that you can use {ABC} style parameter references in a "value changed" script on a member tag in a UDT instance but that appears to resolve the the value of the parameter the last time the UDT instance was restarted, not its current value.

Update: Looks like this documented behavior. Still adding my comment here as a breadcrumb for the next person who forgets the right place in the documentation to find this info.
(Tag Event Scripts - Ignition User Manual 8.1 - Ignition Documentation)


I rediscovered this bug/behavior today in v8.1.35. Cross-posting here as it has some relevance. It seems Ignition attempts parameter resolution even on commented lines and will fail silently if there is something in curly brackets that is not a valid parameter.

1 Like