HI Folks,
I want to move the Memory Tag "MYTag" from the UDT Definition "My Definition 1" to "My Definition 2". Once the tag is successfully added to "My Definition 2", it should be removed from "My Definition 1".
I’m executing the script in the Script Console, and I’ve written a script to get both UDT configurations, extract the tag, transfer it, and apply changes using system.tag.configure().
-->Script:
from com.inductiveautomation.ignition.common.tags.paths.parser import TagPathParser
try:
fromPath = "[default]types/My Definition 1"
toPath = "[default]types/My Definition 2"
# Get UDT definitions
fromDef = system.tag.getConfiguration(fromPath, True)[0]
toDef = system.tag.getConfiguration(toPath, True)[0]
# Extract internal tags
fromTags = fromDef.get("tags", [])
toTags = toDef.get("tags", [])
# Find and remove MYTag
tagToMove = None
newFromTags = []
for tag in fromTags:
if tag.get("name") == "MYTag":
tagToMove = tag
else:
newFromTags.append(tag)
if tagToMove is None:
print("MYTag not found.")
else:
toTags.append(tagToMove)
fromDef["tags"] = newFromTags
toDef["tags"] = toTags
fromDef["path"] = fromPath
toDef["path"] = toPath
# Correct usage: convert string to TagPath
basePath = TagPathParser.parse("[default]types")
system.tag.configure(basePath, [fromDef, toDef], "m")
print("MYTag successfully moved from My Definition 1 to My Definition 2.")
except Exception as e:
import sys
print("Error:", str(e))
sys.printException(e)
--> i am getting the error message as well "MYTag successfully moved from My Definition 1 to My Definition 2. ", but nothing is moved.
-->this is the error message:
[Error_Configuration("java.lang.ClassCastException: class java.lang.String cannot be cast to class com.inductiveautomation.ignition.common.tags.model.TagPath (java.lang.String is in module java.base of loader 'bootstrap'; com.inductiveautomation.ignition.common.tags.model.TagPath is in unnamed module of loader java.net.URLClassLoader @3099f5ed)"), Error_Configuration("java.lang.ClassCastException: class java.lang.String cannot be cast to class com.inductiveautomation.ignition.common.tags.model.TagPath (java.lang.String is in module java.base of loader 'bootstrap'; com.inductiveautomation.ignition.common.tags.model.TagPath is in unnamed module of loader java.net.URLClassLoader @3099f5ed)")]
MYTag successfully moved from My Definition 1 to My Definition 2.
can u please look in to this issue and provide a fix.
Regards,
Adarsh R SPreformatted text