System.tag.browse OR in filter

Paul specifically said you can't just supply two dict keys with the same name as you've done, as it just gets overwritten to the last value. You need to use his class method, which he also states may or may not work

Otherwise, you could probably use the tag report function instead

1 Like

A few pointers about dictionaries to help you understand why this can't work:
dictionaries are a mapping between keys and values:

{
  'key1': value1,
  'key2': value2,
  ...
}

Keys need to be a hashable type, values can be anything.
Dicts will allow you to retrieve a value based on a key.
This implies that keys must be unique, as otherwise you wouldn't be able to retrieve values predictably.

You can overwrite keys as much as you want, but this means the previous ones do not exist anymore. Even in one single declaration:

{
  'name': value1,
  'name': value2,
  ...
}

This will result in only one 'name' key. Most likely the last one, though I'm not even sure you can predict that - probably dependent on the dict class implementation.

If you need to filter on several different typeId, you'll need to either do as many searches them merge the results if needed, or you may be able to use a wildcard in the value : {'typeId': "*_DDT"} (the doc mentions this about the 'name' key only, but it's worth a try)

1 Like

Hoo thank you very mutch for the explanation am gonna take a look on monday morning. Your Time is vert appreciate!

I try witht thw wildcard.

Filter = {'typeId': "MOTOR_DDT", 'typeId': "*_DDT","tagType":"UdtInstance","recursive":True}

results = system.tag.browse("[default]", Filter).results
for result in results:
	print str(result['fullPath'])

But it doesn't work. Am gonna try a merge.

You still have entries with the same key in your dictionary. Remove the first one, then retry.

Yes my mistake. But I try again and still not working ..

But I use now a Tag Browse Tree and I make this filterTag script and look like I want.

udtList = ["AIN_DDT","ALM_DDT","DIDO_DDT","MOTOR_DDT","PID_DDT","TOT_DDT","TRIP_DDT","VALVE_DDT"]
	from com.inductiveautomation.ignition.common.tags.config.types import TagObjectType
	
	if tag.objectType == TagObjectType.Folder:
		for x in udtList:
			r1 = system.tag.browse(tag.fullPath,{'tagType':'UdtInstance',"typeId":x,'recursive':True}).getResults()
			if r1:
				return True
	
		return False
	if tag.objectType == TagObjectType.UdtInstance:
		parentConfig = system.tag.getConfiguration(tag.fullPath,False)
		
		if parentConfig[0]['typeId'] in udtList:
			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
		
		
	if tag.objectType == TagObjectType.AtomicTag:
		parentConfig = system.tag.getConfiguration(tag.fullPath.parentPath,False)
		tagConfig = system.tag.getConfiguration(tag.fullPath,False)
		if tagConfig[0]['tagType'] == TagObjectType.AtomicTag:
			return False
		if parentConfig[0]['tagType'] == TagObjectType.UdtInstance:
			return True
		else:
			return False
	return False

It’s probably not really optimized but not sure how to optimize that more. I haven’t seen enough example..
image

What's the goal of this script ?
And can you edit it with the actual indentation ? I mean, the indentation here seems a bit off, which is usually a result of copy-pasting.

edit: Actually it may not be the indentation, but there's a block that's rendered obsolete by a return True, kinda threw me off.

The result that I want is a list of tag from my project with the same folder and structure but only stop at a certain UDT Type if its an other type tags that a UDT then I dont want it. But inside a UDT Motor there is a lot a tag, folder and other UDT so I want to stop at parent level and not looking all UDT just a list of them. That is the idea behind. I got some folder that I don't want too.
Picture of actually tag structure into the designer tag browser :

Picture of I done with the filterTag script into the component Tag Browser(Its working but like you said its probably not script well..am pretty new and I learn by my own some probably have not the base):
image