What is the best way to use a PLC tag to change a window on a project on Ignition?
Say I have a Tag called 'Screen 1' that was controlled by input on a HMI, could I write a client event script that takes the tag value and selects a screen based of the value?
value = system.tag.read('Screen 1').value
if value==1:
system.nav.SwapTo('window 1)
elif value==2:
system.nav.swapTo('window 2')
elif value==3:
system.nav.swapTo('window 3')
It's my first time doing something like this so any guidance would be appreciated.
Yeah, don't. This is an anti-pattern that will cause you much grief, since it typically requires considerable effort to confine to the one client instance that should respond, and makes working in the designer difficult.
This pattern comes from the ideas and typical requirements of a single, tightly integrated on-machine HMI, where there's no concept of "scope" as used in Ignition. Don't do it.
{ I adjusted your topic tags to include Vision, as system.nav.* is Vision-only. The link to system.perspective.navigate() is not applicable. }
Not really "no go", but a "do you really need this?"
If you must, within the client tag change script, include a check for the specific client's MAC ID, or something else unique, and only perform the navigation if it matches. That'll keep your designer from firing on it while in preview mode.
You can perform that MAC ID check once in a client startup event and save the result to a client tag (if you have other things that should be limited to that one client). See this topic for a method: