Referencing UDT Instance Tags in Vision Client Script

I’m looking for advice on how to properly work with UDT Instances in a Vision script.
Here’s the setup:

  • UDT Instance of type “Tester” called “Tester_1”
  • The window has a custom property “selected_tester” of type Tester
  • I bind the UDT Instance tag “Tester_1” -> the “selected_tester” property
  • The vision client window has complex scripts that read / write tags in the UDT

What I’m trying to do in the script is reference the UDT Instance elegantly with:

event.source.parent.selected_tester.SN = ‘xxxxx’

Instead of with a parameterized path:

system.tag.write(’[default]Testers/{event.source.parent.path}/SN’, ‘xxxxx’)

The problem: When I write to the SN tag, the Custom Properties viewer shows the SN value getting assigned to the SN tag, but the associated OPC Tag is not being affected. It’s like the UDT Instance “passed in” to the custom property is a copy of the object - not a reference to the original UDT Instance.

Is there a right way in scripting to work directly with UDT instances as objects? Thanks!

Is your binding to selected_tester bidirectional?

1 Like

:man_facepalming: I had taken pains to put all the component bindings to bidirectional - but failed to do so on the Custom Property. Imagine that, it works now. :slight_smile: Thank you.

1 Like