How to filter tags and folders in all tag tree browser using one common script instead of running script in all tag tree browser?

Hi, i am using tag tree browser in my project in different modules

In future if customer adding a folder called system tags that i want to hide, but instead of going to every tag tree browser and write script in filter tag

i want to write common script that has to hide folder in all tag tree browser in different modules

Is this possible to do?

def filterTag(self, tag):
	Called for each tag loaded into tag browse tree. Return false to hide this
	tag from the tree.

		self: A reference to the component that is invoking this function.
		tag: The tag itself.
	if == 'Parameters':	# Hide "Parameters" for UDTs tags
		return False				# Hide tag
	elif == 'Node Control':
		return False				# Hide tag
	elif == 'Node Info':
		return False				# Hide tag
	elif == 'Device Info':
		return False				# Hide tag	
	elif == 'SystemTags':
		return False				# Hide tag			
	elif == 'Energy' and self.parent.getComponent('DropDown_TreePath').selectedIndex == 1 :
		return False
		return True					# visible tag

i want to use this script in common place for all tag tree browser

please give idea to do this one

Use a project script module. Define your filtering function there. Make all of your tag tree browsers filterTag() methods a one-line call to the project script function.

1 Like

Thanks I will try. Whether I have to use timer for tag tree browser in filter tag to update the project library script in tag tree browser?

No. What I described just puts the code in one place for you to maintain. At it’s simplest, it doesn’t cache any data. Though caching is possible with a top-level variable (dictionary, typically) in such a project script module.

@pturmel i tired but i don’t know how to call the ( Make all of your tag tree browsers filterTag() methods a one-line call to the project script function.)

please give one example how to call it

i will attach code also

def filter(tag1,tag2):
	if == tag1:	# Hide "Parameters" for UDTs tags
		return False				# Hide tag
	elif == tag2:
		return False				# Hide tag

this is the code i have written in project library and image also i have attached

please correct me if i did anything wrong

Your project script function should be exactly like the original component method, accepting self and tag as parameters. Then the new component method will be one line:

    return tag_test.tag_filter.filter(self, tag)

@pturmel understood after finish code in project library

i have to write in tag tree browser like this right?

I think nothing to write in tag tree browser ?

please let me know the next step what i have to do after writing script in project library

I tried to call the project library function in button

But I got like self not defined error. I don’t know how to pass the value to (self and tag) outside

You are missing the return in your screenshot. The filterTag component method must return the filtering instructions. So your one-liner must return the result from the project script.

This project script is only callable from the filtering context. It is meaningless to call from a button or any other outside context.

1 Like

Its working i checked

one question , actually i want filter tag folder selection is to be done by operator in client
i have a module in that they can mention the folder which they don’t want to see
is it possible to pass filter tag path dynamically to project library script?

Sure. Add a custom string property to your tree, and a third argument to your project script function. So the one-liner becomes:

    return tag_test.tag_filter.filter(self, tag, self.myFilterFolder)

Then use that string in the function to condition your filtering. You would bind the string property to a dropdown box or some similar UI component to select your filter condition.

getting error

whether i have to pass like inside project library script

"if == myFilterFolder: ?

if i want multiple folders to hide how to pass arguments?

i want to multiple folder paths to hide how to do that?

In the function definition you can’t use dot notation as a variable name.

Probably the easiest way to filter multiple paths would be to send them as a delimited string.

So you’re custom property would have a value something like:


Then use the split function and the IN keyword to determine if the tag should be filtered or not.

def filter(self, tag, myFilterFolder):
    if in myFilterFolder.split(','):
        return False
1 Like

Understand I will implement and check

getting this error

i can’t able to edit def filterTag(self, tag): in filter tag (tag tree browser)

project library i have return this script


is there any other way to do?

Did you do as @pturmel suggested and create a custom property on your tree?

If you did then you would reference that property in the extension function to send as the parameter to your project script.

The error you are getting is because myFilterFolder is not defined in the scope of the script.

You don’t have to pass it when you are already passing self.

but i am getting error. anything i did wrong?

As you have set it up, myFilterFolder isn’t a variable by itself in the component method. Only self and tag exist there. You can either reference it from self in the component method to pass to the script function, or you can leave off the third argument (in both places) and just use self.myFilterFunction inside the project script.

This is basic python object and function behavior, not anything specific to Ignition. You should consider a python tutorial to fill in the gaps.


I have written inside the project library like this


still getting global name ‘myFilterFunction’ is not defined error

You used myFilterFunction in the if statement, it is still undefined.

def filter(self,tag):
    if in self.myFilterFunction.split(','):
        return false

Can’t like this enough