Tag Browse Tree Filter by Tag Type

Is there anyway to filter the tag browse tree by tag type? i.e. boolean, etc.


1 Like

As far as I know, there’s no easy way to do this. From what I can tell, the tag object offered in filterTag is missing most of its attributes, so the best you can do is invoke tag.getName(). For example:

if ((tag.getName().find("DI_") != -1):
        return False
        return True

The above snippet would exclude all tags with the string “DI_” in the tag name.

I hope to see more robust Tag Browse Tree filtering in future ignition versions.

Your should be able to use .getAttribute(TagProp a) to retrieve the details you need.

How do you get the TagProp to pass into that function?

You could script your own tag browse tree using the standard tree view using functions like system.tag.browseTags

It is an enum. You have to import and use its constants. Something like this:

from com.inductiveautomation.ignition.common.sqltags.model import TagProp
if "whatever" in tag.getAttribute(TagProp.Documentation):
    return True

I think I’ve been doing this wrong. Maybe you can help me out. So, when I enter the following code:

from com.inductiveautomation.ignition.common.sqltags.model import TagProp
print tag.getName() + " -- " + str(tag.getAttribute(TagProp.TagType).value) + " -- " + str(tag.getType())
return True

I get the following output:

MyTagName -- 7 -- External

And every tag has the same output, regardless of type.The only unique value on each line is the tag name.

Try TagProp.DataType.

1 Like

The output is:

MyTagName -- Int4 -- External

for each tag.

I tried changing it to a realtime tag tree instead of historical, and now it shows the right output for datatype. I’ll do some more tests…

I am running into a similar issue. It seems that when the Tag Browse Tree is set to “Tag Tree Mode” = “Historical Tag Tree”, the following is returned for every node

Tag DataType = “Int4”
Tag Type = “External”

Is it possible to detect if a tag is a Folder when the Tag Browse Tree is set to return Historical tags??

I found a work around.

By switching the Tag Tree Mode from “Historical Tag Tree” to “Realtime Tag Tree” and using the following code, based on an example by @pturmel,

from com.inductiveautomation.ignition.common.sqltags.model import TagProp
from com.inductiveautomation.ignition.common.sqltags.model.types import TagType

filter = self.parent.getComponent('Filter').text
if tag.type in (TagType.Folder, TagType.UDT_INST):
	return True
elif tag.getAttribute(TagProp.HistoryEnabled).value :
	if len(filter) > 0 :
		x = all([word in tag.name.lower() for word in filter.lower().split(" ")])
		return x
	else :
		return True
else :
	return False

I can filter the results of the tag tree to contain all folders and only tags that match my filter.

However, this still does not work great because there is no way to clear empty folders. It would be great if there was a setting in the Tag Browse Tree component to hide empty folders. This doesn’t seem possible through the filterTag property or through any other method I can find.