Python: return list of tag data types

Is it possible to get a list of all of the tag data types? E.g. all the types within the Tag browser, Tags->Data Types.

I’m trying to build a simple tool that reports the UDT instances for a selected UDT data type. I’d like to have a drop down list to select a UDT data type from a list, but I can’t find a function to get these from the database… only tags themselves.

Additionally, is it possible to locate tags in the Designer from a vision window? (as in, expand the tag browser to its location)

tags = system.tag.browseTags(parentPath="_types_", recursive =1)
for tag in tags:
	if str(tag.getTagType()) == 'UDT_DEF':
		print tag.name
2 Likes

Interested in data types as well. I would like to get a data type without browsing. If I already know the tag name/path, is this achievable?

Yes if you have the path. Append “.datatype” to the path to read the data type property.

path = "my\tag\path.datatype"
print system.tag.read(path).value
1 Like

So basically, just perform a read and pull the datatype off the qv?

path = "my\tag\path.datatype"
qv = system.tag.read(path).value
print qv.datatype

Correct?

Close. You are actually reading the datatype property of the tag and the result is a qualified value.

The script you posted would need to be this instead:

path = "my\tag\path.datatype"
qv = system.tag.read(path)
print qv.value

Perfect. This works wonderfully. Thanks @JGJohnson

-Leif