Dynamic string path for mouse action

Hello folks,

I am trying to set the value in my OPC dynamic tag using this script, getting error 'Bad Not Found'.
my tag path is correct and tag value quality is good but not sure how to achieve this.

Thanks

Try without the .value

same issue @JordanCClark

Have you tried copying the tag path directly, and see if there are any differences?

Tag path is commented in the script, it is exactly same

Never mind. Don't use tag as a string when you try to write to it. :wink:

Is there any other way to do this?

system.tag.writeBlocking(tag, 1)

Notice no quotes.

in my case all my tags are string like ,

CCV01
CDC01
CDR02

example it shows only Motor1,2,3,-----etc
in my case it must be dynamic string value

Awesome, thanks you are correct @JordanCClark

there is one small correction in my script as it is binding from the container,

#Valve =1

Tagpath1 = "[default]Test/"
Tagpath2 = "{event.source.parent.Valve}"
Tagpath3 = "/Cmd.value"

tag = Tagpath1+Tagpath2+Tagpath3

#system.tag.writeBlocking(["[default]Test/+[str(event.source.parent.Valve)]+/Cmd.value"], [1])

system.tag.writeBlocking(tag, 1)

print(tag)

You can shorten the tagPath to one line using a format method.

tag = "[default]Test/{}//Cmd.value".format(event.source.parent.Valve)
1 Like