Is there a way to access UDT properties inside a script. Basically I want to pass a UDT as a parameter in a script so I could check the properties and do some logic…
No, the only way to get a UDT object is by having a property with the UDT datatype somewhere on the window. You can’t get the UDT object through scripting right now.
Is it still not possible to access a UDT object from a script?
I assume that since ignition can grab a UDT tag and pass it as a parameter, there must be a function (albeit hidden) that can take a tag path and return an list object that contains the UDT values. Does anyone know what this function would be called?
def getAllTheTagz(udtPath):
tagPaths = [tag.fullPath for tag in system.tag.browseTags(parentPath = udtPath, recursive = True) if not tag.isFolder() and not tag.isUDT() ]
_results = system.tag.readAll(tagPaths)
theTagz = {}
for i in range(len(tagPaths)):
theTagz[str(tagPaths[i][len(udtPath):])] = _results[i]
return theTagz
myUDT = getAllTheTagz("[provider]path/to/the/udt")
print myUDT["propertyPath"].value
You can then access the values in an easy manor, such as the last line. If you only need the values, change the _results[i] in the for loop to _results[i].value