List of bindings on a property

Hello! I haven't found any related threads on this topic yet, albeit I did not do a ton of searching as I don't have enough time. Hopefully this post isn't redundant!

I am looking to see if there is functionality in Ignition, hopefully via scripting, that will allow me to list all the bindings on a property.

For example, imagine I had a custom property call LabelText in my root container and there were 4 labels on the screen (maybe even in different groups/containers) that had their text properties bound to this LabelText custom property. I would like to list all the components with their locations and their properties that are bound to this custom property. I would preferably like to do this in scripting.

Is this possible? Thank you for your time!

I played around with the Interface InteractionController java class which I found here, and was not really able to get what you're looking for, but close.

Here's what I did:

  1. Create a test window in Vision (not sure how to make this work with perspective), and place 4 Label components on there.
  2. Create a custom property on the root container and bind the 'text' prop on the labels to the custom property
  3. Place a button on the same container as those labels (root container)
  4. Add the following script to the button
window = system.gui.getParentWindow(event)
Container = window.getRootContainer()
Component_Array = Container.getComponents()


for component in Component_Array:
	print window.interactionController.getPropertyAdapter(component, 'text')

This is what the script returns:
Root Container ---> Label 1
Root Container ---> Label 3
Root Container ---> Label 2
Root Container ---> Label

So it basically tells you that the 'text' prop of each label is bound to a property on the Root Container but it doesn't tell you what the property is. Hope this helps a bit or gets you started somewhere.

This answer assumes Vision, but both Vision and Perspective are tagged.
Are you working in Vision or Perspective? Or are you looking for an answer for both? If so, this should be spelled out in your OP

2 Likes

That's close. I'm actually looking for specifically what it is bound to, but this may be a good lead to work off of. Thank you!

I had hoped by tagging both that I would get a solution for both. Sorry it was not that obvious in my example being I might have alluded to vision with my terminology.

A lot of the time, when someone tags both Vision and Perspective, they actually have no idea what perspective is but tag it anyway I guess to get more exposure. Unfortunately that means that people such as yourself, lose out by us assuming you've tagged the wrong things :grimacing:

This is technically possible in Perspective as well by reading the View's json from its file resource. I can get you more info in a few hours

haha, sounds about right :stuck_out_tongue: and awesome! I figured it was probably easier in perspective, anyway, haha.

This script will get you the file path to the Ignition projects directory:

from com.inductiveautomation.ignition.gateway import IgnitionGateway
context = IgnitionGateway.get()
projectParentFolder = str(context.systemManager.dataDir.absoluteFile).replace('\\','/') + '/projects/'

From there, you should be able to traverse the structure to find your View and read its view.json file, interpret it as json with system.util.jsonDecode, and find your bindings.

Note, this will only run in the gateway scope, so script console is out (unless you indirectly run it from there on the gateway). Running it from a Perspective button will work though.

You can also reference @rbabcock 's Theme Manager View code for an example of how to traverse the file structure. Incidentally, this is a pretty useful resource to have as well!

3 Likes

Thanks for the help! This is awesome and is actually going to help me with some other things I'm working on as well! You are right, this Theme Manager is also a pretty useful resource outside of being a good example. :sunglasses: