I am looking to be able to read the name of a tag if its value meets a condition:
Taglist = [
"Tag 1",
"Tag 2",
"Tag 3",
"Tag 4"
]
Tag_path2 = [
"Tag 1",
"Tag 2",
"Tag 3",
"Tag 4"
]
Tag_Read= system.tag.readBlocking(Taglist)
Tag2_Read= system.tag.readBlocking(tag_path2)
for i in range(len(Taglist)):
mode = Tag_read[i].value
name = Tag_read[i].name
split = name.split()
fixedname = split[1]
if mode == "OPEN":
Thing += Thing1 + Thing2
comparator= system.tag.readBlocking(tag_path2)
for j in range(len(tag_path2)):
linetk = comparator[j].value
line = comparator[j].name
linesplit = line.split()
runline = linesplit[0] + linesplit[1]
if fixedname == linetk:
Obviously you can''t do system.tag.read the name component of a tag. Is there any other way of reading a name of a tag, so you can use it in comparisons? Any help would be appreciated, thanks!
Perhaps I'm misunderstanding your intent, but since you're iterating over a range equivalent to len(TagList), couldn't you just access the tag name (tag path) in your original list? With
There's a lot of things that might "work" but are definitely not ideal about the code you've written.
Can you take a step back and describe what you're trying to do in more detail? Where are you running this script/what is it reacting to, what do you want it to do, how often do you want it to run, that kind of thing.
You might be able to use the Tag Report Tool to generate a script for this. Simply add a Tag Path filter and add a property condition to match with what you want.