Accessing object binding tag path trough scripting

Hi,

I want to write a script that would change the name of a list of tag inside a folder, and update all the objects in all the windows that are bound to these tag.

In my case, I would change UDT tags name and update template instances. This is what I have done so far:

[code]Window = system.gui.getParentWindow(event)
WindowComponents = Window.getRootContainer().components

for Component in WindowComponents:
if type(Component).name == “TemplateHolder”:
print Component.getProperties()
print Component.getProperties()[0]
print Component.getProperties()[0].value
print type(Component.getProperties()[0].value)[/code]

This is implemented in a button actionPerformed Script Editor. It gets all the component inside the window and keep only those which are template instances.

My UDT is called TestScriptTag and contains a memory tag called String.
My template contains a label bound to the tag name, and has a external property bound to the UDT TestScriptTag.

This is what I get for the print at the end:
array(com.inductiveautomation.factorypmi.application.binding.DynamicPropertyDescriptor, [Test])
Test
TemplateHolder.DelegateUDT[type=,path=]
<type ‘com.inductiveautomation.factorypmi.application.components.template.TemplateHolder$DelegateUDT’>

Here is my question, how can I modify the binding? I want to write write a tag path.

1 Like

Has anyone succeeded to change a binding through scripting?

I have played with the binding system a bit, including creating bindings from scratch. I must have missed a few operations here and there, because windows with modified bindings didn’t work correctly until saved, closed, and reopened (in the designer). It wouldn’t surprise me if such operations scrambled a saved window entirely. I have some suspicions what might have been needed, but none of this stuff is documented for us to use. Basically, you’ll have to access the InteractionController of the window, find the appropriate PropertyAdapters and replace them with your own.
Good luck, and backup your gateway often.

1 Like