I am currently trying to get the Tag Brwoser Tree to only display the UDTs. I have tried to change the root source to match "[provider]types/" but it doesn't work. Any suggestions on how to get it to work?
Where was that documented?
It is actually [Provider]_types_/
with underscores, but was styled in his post.
Don't know about documentation, but it copies it with the tag path from the designer tag browser.
Vision or Perspective?
Generally, you would treat them similarly to folders. Are you trying to only show UDT's? Do you want UDT Instances or UDT Definitions?
I think the tag browsers filter out the definitions themselves.
The workaround I found, for now, was to set up a script that makes a list with all UDTs, converts the list to a dataset, and use it in combination with the Tree View component.
If what you are trying to present is a view of the UDT Definitions then, I believe your way is the only way.
If however you want to show UDT Instances, then you can do that with the Tag Browse Tree.
In the filterTag
extension function use this script. It will filter out all tags except those which are UDT instances, and Atomic tags that are children of a UDT Instance.
NOTE: This assumes a Tag Browse Tree in Vision
from com.inductiveautomation.ignition.common.tags.config.types import TagObjectType
if tag.hasChildren() or tag.objectType == TagObjectType.UdtInstance:
return True
if tag.objectType == TagObjectType.AtomicTag:
parentConfig = system.tag.getConfiguration(tag.fullPath.parentPath,False)
if parentConfig[0]['tagType'] == TagObjectType.UdtInstance:
return True
return False
I suppose it is also possible to browse forward and determine if a folder has any children that should be displayed, effectively eliminating "Empty Folders". Beware though, you're calling a potentially long running task here so the result may be less than desired. If you have a moderately large tag structure, you should almost certainly off load this to a back ground thread. As it is, it will lock up the GUI until the filter is completed (I have around 30K tags and it took ~2s). Basically, I'm too lazy to do it right now.
###################
#Caution: This is a potentially long running task that will block the gui thread while
#it executes.
from com.inductiveautomation.ignition.common.tags.config.types import TagObjectType
if tag.objectType == TagObjectType.Folder:
results = system.tag.browse(tag.fullPath,{'tagType':'UdtInstance','recursive':True}).getResults()
if results:
return True
return False
if tag.objectType == TagObjectType.UdtInstance:
return True
if tag.objectType == TagObjectType.AtomicTag:
parentConfig = system.tag.getConfiguration(tag.fullPath.parentPath,False)
if parentConfig[0]['tagType'] == TagObjectType.UdtInstance:
return True
return False
I needed something like this for Perspective… didn’t find anything; this works:
def filterBrowseNode(self, node):
"""
Production version of filter: Includes folders and UDT instances, with minimal error handling.
"""
try:
# Get node details
name = node.getName()
object_type = str(node.getObjectType()).strip().lower() # Normalize ObjectType to a string
full_path = node.getFullPath() # Retrieve node's full path
# Allow folders
if object_type == "folder":
return True
# Allow UDT instances
if object_type == "udtinstance":
return True
# Exclude everything else
return False
except Exception as e:
# Log unexpected errors for diagnosis
system.perspective.print("ERROR in filterBrowseNode: {}".format(str(e)))
return False