Changing Perspective component properties with scripting

Hello, I'm having trouble finding information on how to edit properties with scripting. I have about 50 labels that need to have their tag binding switched to indirect, select a custom property in the container, and change the device name in the binding.

I know that system.tag.configure can create tags for you, and I guess I was wondering if there was a similar function for perspective properties. Any time I try looking up scripting and perspective properties, I keep getting met with property change scripts, which I might be able to use really creatively, but Iet me know what you guys think.

Anything helps and thank you!

You cannot edit perspective bindings with scripts from within Ignition. You may be able to automate what you want with jquery jq (whoops..) outside Ignition, using your view's JSON. (Shift-right-click in the designer tree.)

1 Like

Probably meant jq, not jquery :smile:

Unironically the best way I've found to use jq is to give ChatGPT et-al the snippet of JSON I have, describe the transformation I want, and let it give me the arcane snippet I need to achieve the desired result.

2 Likes

I don't know JavaScript nor jq, so I was thinking of plugging the whole thing into Chat GPT lol. I'm open to learning, but I think at this point I should just brute force it. I think I could've gotten done by now. I will definitely experiment with it though. If you have any resources, I would love to have them

Actually, it's a C program not JavaScript my bad

An example of a usage of jq applied to Ignition:

2 Likes

I've had success copying the view as JSON (shift-right-click, copy json), modifying it in a text editor and pasting it back in.

  • Note/Warning: You have to paste your modified JSON back to the containing folder and it will just overwrite without further (any) warning/prompt the view that you copied the JSON from. You could paste to different folder if you like.
  • I suggest a healthy knowledge of regular expression find and replace features in your given text editor for this to be efficient (I've been using Notepad++ for regular expression manipulations).

I'd guess the aforementioned jq would be a better option but I don't know it (something new to learn I 'spose), I do however know the joy that crafty use of regular expressions can bring to one's soul and thought I mention it as an option.

In any case it might be worthwhile checking your manipulated JSON in a JSON validator before pasting it back in Ignition.

2 Likes

I consider regex absolutely worth learning, because it's applicable in basically every general purpose language. jq's weird syntax, like awk, has not cleared that bar for me personally, because it's only useful when using jq. Hence, LLM assistance. It's nice also that jq, as long as it works, is ~guaranteed to spit out valid JSON with no funky syntax errors from a missing quote/curly brace/comma. But definitely nothing wrong with the regex approach :slight_smile:

3 Likes