Configure bindings with script

Is there any way we can configure bindings on a particular component through scripting.

Nope.

What do you want to do ?

1 Like

I wish.

You could, by getting the view json with IgnitionGateway.get(), editing this json the way you want, and writing it back to the correct location.

Here is a code that should do the trick:

from com.inductiveautomation.ignition.gateway import IgnitionGateway
context = IgnitionGateway.get()
path = "%s/projects/YOURPROJECT/com.inductiveautomation.perspective/views/YOURVIEW/view.json"%(str(context.systemManager.dataDir.absoluteFile).replace('\\','/'))
json = system.file.readFileAsString(path)
data = system.util.jsonDecode(json)

#You edit the json here

new_json = system.util.jsonEncode(data)
system.file.writeFile(path, new_json)

Note that you'll have to wait a few minutes for the changes to be applied

What are you trying to accomplish?

2 Likes