You could turn it into a one liner if you want, but gets a little harder to interpret:
return any(sub_path in str(tag.getFullPath()) for sub_path in self.myFilterFunction.split(','))
Edit: Whoops, sorry, this does the opposite of what you want…my bad. This should be correct:
return all(sub_path not in str(tag.getFullPath()) for sub_path in self.myFilterFunction.split(','))
self.myFilterFunction = [Line/Common,Line/Fiberizing]
for x in self.myFilterFunction .split(',') :
if x in str(tag.getFullPath()):
return False
else:
return True
But its not hiding the folder..
any thing i have did wrong?
In this script
> if self.myFilterFunction.split(',') in str(tag.getFullPath()):
> return False
> else:
> return True
which line i have to replace your script?
return all(sub_path not in str(tag.getFullPath()) for sub_path in self.myFilterFunction.split(’,’))
You’ll need to change it up a bit. As soon as a return happens the function is over, and it goes on to the next tag.
for x in self.myFilterFunction .split(',') :
if x in str(tag.getFullPath()):
return False
return True
2 Likes
You would replace all lines, and if would become just that one line. Like I said, it’s harder to read though, so you’re probably better off continuing with getting your for loop working.
1 Like
The one-liner won’t break out early at the first match. I’d still use a loop.
@prasath.t : I don’t see any obvious error. Jordan saw it.
2 Likes
Good point, didn’t think of that
JordanCClark:
.split(',')
Still folder is not hiding
any change to be done?
Your property is a string. Ditch the square brackets.
3 Likes
skumar
June 7, 2021, 9:58am
53
I’m Trying to hide the Add Mixer folder but following steps from above no changes, The folder still shows up in Tag Tree Browser.
Tried ‘All Providers/default/Add Mixer’
Tried ‘default/Add Mixer’
Tried ‘Add Mixer’
I’m new to Ignition and scripting.
lrose
June 7, 2021, 12:01pm
54
Try the following:
if tag.name == 'Add Mixer':
return False
else:
return True
2 Likes
Hello, I’m new to using Ignition - Vision and I would like to know if there is a way to do the opposite of this script, instead of writing all the folders that I don’t want to show, I would like to write /filter only the one I want. That is, in the property I created xFiltro, write the name of the folder that should be shown, because I have 50 folders, imagine writing them all…
Thanks in advance for your help.
andreia_chiurato:
the opposite
replace the True with False and visa versa xd
or add a not
in front of the in
Thanks @victordcq ,but didin’t work.
Then you probably got something wrong else where, because adjusting one of those things littlerly makes it opposite xd
show me your code
lrose
February 2, 2022, 7:19pm
62
You have to be careful here with your filtering.
This:
if self.xfilter in str(tag.getFullPath()):
return True
else:
return False
Is logically and functionally equivalent to:
if sefl.xfilter not in str(tag.getFullPath()):
return False
else:
return True
If both cases if the filter is in the tag path it will return True. You can only switch the logic in one place or the other.
The key here is you need to return False for any tag which should be hidden in the tree. I would tend to write it this way:
if self.xfilter in str(tag.getFullPath()):
return True
return False
This suggests that self isn’t what you think it is, and thus self.xfilter is not what you’re expecting.
try this and see what prints out in the console:
print type(self)
if self.xfilter in str(tag.getFullTagPath()):
return True
return False