Ignition Tag Count in a project

Is there any way to calculate total numbers of tags used in ignition project.

This will give you the total number of Ignition tags in a tag provider, and summarise them by different properties.
Run this in the script console, preferably directly on the GW server.

"""
Produces a summary of tags.
Example output:

Tag summary
========================
tagType: {'UdtInstance': 43, 'Folder': 95, 'AtomicTag': 644}
valueSource: {'memory': 197, 'opc': 391, 'reference': 1, 'expr': 47, 'derived': 2, 'db': 6}
dataType: {'Float4': 2, 'Int2': 3, 'DataSet': 43, 'Float8': 18, 'Int4': 295, 'String': 32, 'Int8': 27, 'Document': 3, 'Boolean': 221}
tagGroup: {'Default': 741, 'Alarm Summary': 18, 'ConfigTags_CMDPLCReset': 7, 'Value Change Triggers': 16}
"""

provider = 'default'
# list of tag properties to include in the summary. Must be valid tag properties
tag_summary_properties = ['tagType', 'valueSource', 'dataType', 'tagGroup', 'eventScripts', 'historyEnabled']
query = {
	"options": {
		"includeUdtMembers": True,
		"includeUdtDefinitions": False
	},
	"condition": {
		"attributes": {
			"values": [],
			"requireAll": True
		}
	},
	"returnProperties": tag_summary_properties
}

print 'Tag summary'
print '========================'
tags = system.tag.query(provider, query)
for tag_summary_property in tag_summary_properties:
	tag_summary = {}
	for tag in tags:
		if tag_summary_property in tag:
			if tag_summary_property == 'eventScripts':
				if tag['eventScripts'] is not None and tag['eventScripts'][0].get('enabled', True):
					a = tag_summary.setdefault('eventScripts', 0)
					tag_summary['eventScripts'] += 1
			else:
				a = tag_summary.setdefault(str(tag[tag_summary_property]), 0)
				tag_summary[str(tag[tag_summary_property])] += 1
	print '{}: {}'.format(tag_summary_property, tag_summary)

If you do end up using this, I wouldn't mind knowing what it returns :slight_smile:

1 Like

Hello, if it is only to show the number of tag used, you can go to the main status > Overview page on the Ignition Gateway.
image

Hi nminchin,
I used the gateway option to get total count,
apologize i didn't use the script , thanks for the reply :slight_smile:

The gateway method counts folders, udt instances, and udt definitions tags as well, so it's not really a good count of tags in use

2 Likes