# Auto-rotate through windows

**URL:** <https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388>\
**Category:** Ignition\
**Created:** [October 8, 2013, 6:48pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388 "2013-10-08T18:48:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfarnes](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@dfarnes](https://forum.inductiveautomation.com/u/dfarnes)\
**Post date:** [October 8, 2013, 6:48pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/1 "2013-10-08T18:48:26Z")

</div>

Greetings All, I’m working on an existing project that will auto-rotate through several screens on a big screen TV. Below is the existing script, however it throws an “uncaught exception” error. I would appreciate any help with this script, or any thoughts on another way to accomplish this.

```auto
tagPath = "[Client]TV1_SWAP" % system.net.getHostName()
x = system.tag.getTagValue(tagpath)
windows = [MGMT/TV_PKG_BY_SHIFT, MGMT/TV_CUSTOM]

if x >= len(windows):
     x = 0

system.nav.swapto(windows[x])
system.tag.writeToTag(tagPath, x+1)
```

---

<div class="post-metadata">

**Author:** ![dfarnes](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@dfarnes](https://forum.inductiveautomation.com/u/dfarnes)\
**Post date:** [October 8, 2013, 8:44pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/2 "2013-10-08T20:44:01Z")

</div>

As a follow-up question, the IA demo project has a screen that uses a timer and signal generator to animate a component, effectively rotating out of view, and setting the visible/hidden property. Is it possible to do the same thing with an entire template? I don’t see X-Y positioning properties for a template but wonder if I’m missing something? Animated templates would serve my needs nicely if it’s possible.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [October 8, 2013, 11:00pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/3 "2013-10-08T23:00:40Z")

</div>

Well, I think I can see two problems right off the bat.

1. Your swapto() function needs a capitol t. ie: system.nav.swapTo()
2. Your window names should be strings.

In a semi-unrelated note, I’d rewrite you script like this:`tagPath = "[Client]TV1_SWAP"
windows = ["MGMT/TV_PKG_BY_SHIFT", "MGMT/TV_CUSTOM"]
x = system.tag.read(tagPath).value%len(windows) # mod 2 produces a 0 or a 1
system.nav.swapTo(windows[x])
system.tag.write(tagPath, x+1)`That way, all you need to do is add more screens to the windows list and it will continue to work right.

And for your second question, Templates don’t have rotation or x/y properties. You can set the component’s size and location with system.gui.reshapeComponent() though.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 9, 2013, 5:21pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/4 "2013-10-09T17:21:32Z")

</div>

Using a Client Timer Script…

This cycles through a number of screens (in this case Screen1, Screen2, etc.) Note that I check to ensure that the value is in a valid range before trying to change the display.

`val = system.tag.getTagValue("[Client]Screen")
maxScreens=system.tag.getTagValue("[Client]MaxScreens")
val = val + 1
if (val>MaxScreens):
	val=1
WindowName = "Screen " + str(val)
system.nav.swapTo(WindowName)
system.tag.writeToTag("[Client]Screen", val)`

Alternative way would be to shorten to this (without the swapTo):

`val = system.tag.getTagValue("[Client]Screen")
maxScreens=system.tag.getTagValue("[Client]MaxScreens")
val = val + 1
if (val>MaxScreens):
	val=1
system.tag.writeToTag("[Client]Screen", val)`

Set all your screens to open at startup. Then set the Layer property to a higher value for each display I’ve used a value of 1 for the background, and 2 for the foreground. Just because I’ve occasionally had odd things happen using layer 0. There is a longer startup time, depending on the number of screens, but swapping layers instead of swapTo is much faster once it’s loaded up.

---

<div class="post-metadata">

**Author:** ![dfarnes](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@dfarnes](https://forum.inductiveautomation.com/u/dfarnes)\
**Post date:** [October 9, 2013, 5:46pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/5 "2013-10-09T17:46:06Z")

</div>

Hi Robert,

You are a lifesaver, this worked beautifully!

Maybe I’m just missing it, but how do you mark a post as “solved”? Or is that something you have to do?

Thanks again,  
Dana

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 9, 2013, 6:09pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/6 "2013-10-09T18:09:42Z")

</div>

at the lower-right corner of each post in the thread (has to be one that you started) there’s a ‘Solved’ button…[attachment=0]10-9-2013 2-06-02 PM.png[/attachment]

Glad it’s all working for you! 😃

---

<div class="post-metadata">

**Author:** ![rstevenson](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rstevenson](https://forum.inductiveautomation.com/u/rstevenson)\
**Post date:** [August 5, 2019, 3:09pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/7 "2019-08-05T15:09:48Z")

</div>

As someone who is still learning to use Ignition, which component/where should I put this script to switch windows??

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 5, 2019, 3:23pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/8 "2019-08-05T15:23:40Z")

</div>

In v7, it would be found in _ **Project -\> Scripts -\> Client Event Scripts** _.

In v8 it’s in _ **Vision -\> Client Events** _

---

<div class="post-metadata">

**Author:** ![rstevenson](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rstevenson](https://forum.inductiveautomation.com/u/rstevenson)\
**Post date:** [August 5, 2019, 3:24pm UTC](https://forum.inductiveautomation.com/t/auto-rotate-through-windows/7388/9 "2019-08-05T15:24:41Z")

</div>

Thanks for the insanely quick reply! We are currently using 7.9.9 but are soon upgrading to 8.0.2, so thank you for the clarification!
