Export/Extract tag path for OPC tags based on scanclass

Hi All
I’m trying to export the tagpaths for multiple tags based on a particular scan class on my Ignition project. I tried to load the configuration file (config.idb) in MySQL lite and get it from there but no luck. I also tried to use scripting: system.tag.browseTags() to get the list of tags and sort according to the scan class but no luck there either.

This is the code snippet that I ran as a project script:

def tagpath():
tags = system.tag.browseTags(parentPath="", recursive=True)

for tag in tags:
	tagScanclass = tag.name + ".Scanclass"
	tag2 = system.tag.read(tagScanclass)
	if tag2.value == 'my_scanclass_name':	
		print tag.path + "," + tag2.value

The ultimate aim is to export the OPC item path with the node id, device and path but if I can get at least the tagpath that would be great.
If anyone could think of a better way of doing it please leave a comment. Thanks in advance!

I need to do a similar thing here. Did you figure it out or does someone know how to accomplish this?

I can set the scan class through scripting but can’t figure out how to get the scan class through scripting to filter on.

I’m trying to change the the scan class through scripting in a particular folder. The original scan class is Default so it doesn’t show up in the xml export since only non default settings show up there. It does show in the csv export but I can’t use that because some of the tags have alarm configuration which is not included in the csv. I tried anyway hoping it would leave those settings alone but it stomped on all the alarm configurations and they disappeared.


I was able to export the tag paths from the config.idb file later on. In my case, I used a custom scan class so it might not work for you but give this a shot,

  • Get the config.idb from the computer where the gateway is installed

  • Use SQLite, an application for viewing the idb file

  • Run this query (might need some modification)

select t.name as tag,p.strval as OPC_Path from sqltag t
inner join sqltagProp p on t.sqltag_id=p.tagid and p.name=‘OPCItemPath’
where t.scanclass=‘name of scan class

  • After you get the list maybe you can set the scan class through scripting since you already have the filtered tags that you need.

Hope this helps. Out of curiosity, what function did you use in your script to set the scan class?

The following code works?

def tagpath():
	tags = system.tag.browseTags(parentPath="MyTagFolder", recursive=True)
	tagList = []
	for tag in tags:
		tpaths = ["[default]"+tag.path+".ScanClass","[default]"+tag.path+".OPCItemPath"]
		tinfo = system.tag.readAll(tpaths)
	return tagList
ret = tagpath()
print ret

Thanks sathianandan! I had no idea you could look at and modify the config.idb with sql. I will try this. As for how I modified the scan class below is my script. I filtered on tag type but cannot figure out out to filter on scan class.

folder = "PLC/SP" + str(sp) + "_INT"
tags = system.tag.browseTags(parentPath=folder,recursive=True)
for tag in tags:
	if str(tag.type) == "OPC":
		tagPath = tag.path
		print tagPath
		system.tag.editTag(tagPath=tagPath,attributes={"ScanClass":"Default 2"})

Thanks for posting this MMaynard. Looks like a different way to go about changing the scan class from how I did it (just posted script). Do you know how to filter by scan class? In other words add an if statement to your script that evaluates for a specific scan class and then changes is using your script.

Now I see MMaynard. Your script does get the scan class. I think this will work. Thanks again!