Trying to do something a bit difficult: change UDT parameters using a expression tag’s value change event.
Someone else already did the hard work: figured out how to write UDT parameter in runtime.
Here is the code:
from com.inductiveautomation.ignition.common.config import Property, BasicProperty
from java.lang import String
def writeUDTParameter( tag, key, value ):
propertiesList = system.tag.read( ‘%s.ExtendedProperties’ % tag ).value
propertiesList.set(BasicProperty( key, String ), value)
system.tag.editTag( tagPath=tag, attributes={ ‘ExtendedProperties’: propertiesList } )
Code works fine in the Script test window. Put it into the shared Script library, and when I call it from the Tag Change event:
shared.writeUDTParameter(’[default]San Antonio/DailyTest/DailyFloats’, ‘monthtgt’, currentValue.value )
I get this error:
File “tagevent:valueChanged”, line 2, in valueChanged
AttributeError: ‘com.inductiveautomation.ignition.common.script.Scr’ object has no attribute ‘writeUDTParameter’
I am pretty novice with scripting, so I am probably just getting some of the syntax wrong. Any help would be appreciated.
Thanks!