# Change viewport programmatically

**URL:** <https://forums.creativeclouddeveloper.com/t/change-viewport-programmatically/8614>\
**Category:** Photoshop\
**Created:** [November 1, 2024, 12:53am UTC](https://forums.creativeclouddeveloper.com/t/change-viewport-programmatically/8614 "2024-11-01T00:53:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrhubo](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mrhubo](https://forums.creativeclouddeveloper.com/u/mrhubo)\
**Post date:** [November 1, 2024, 12:53am UTC](https://forums.creativeclouddeveloper.com/t/change-viewport-programmatically/8614/1 "2024-11-01T00:53:30Z")

</div>

Is there a way I can change the viewport (pan and zoom) to a specific layer programmatically with a UXP plugin?

---

<div class="post-metadata">

**Author:** ![shuji](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/shuji/32/4905_2.png) [@shuji](https://forums.creativeclouddeveloper.com/u/shuji)\
**Post date:** [November 1, 2024, 3:20pm UTC](https://forums.creativeclouddeveloper.com/t/change-viewport-programmatically/8614/2 "2024-11-01T15:20:32Z")

</div>

There is an answer in this topic

[http://forums.creativeclouddeveloper.com/t/is-posible-to-set-a-zoom-event/5268/1](http://forums.creativeclouddeveloper.com/t/is-posible-to-set-a-zoom-event/5268/1)

---

<div class="post-metadata">

**Author:** ![mrhubo](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mrhubo](https://forums.creativeclouddeveloper.com/u/mrhubo)\
**Post date:** [November 3, 2024, 4:43am UTC](https://forums.creativeclouddeveloper.com/t/change-viewport-programmatically/8614/3 "2024-11-03T04:43:41Z")

</div>

Thanks @shuji, is there any documentation on how to do setPanZoom? I can’t get the x and y value to work as it should be. I assume those are in pixel?

---

<div class="post-metadata">

**Author:** ![shuji](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/shuji/32/4905_2.png) [@shuji](https://forums.creativeclouddeveloper.com/u/shuji)\
**Post date:** [November 3, 2024, 7:27am UTC](https://forums.creativeclouddeveloper.com/t/change-viewport-programmatically/8614/4 "2024-11-03T07:27:22Z")

</div>

This isn’t written on document anywhere. Batch play could access native application’s function which API cannot access, but you need to inspect by yourself.  
In terms of x and y values, apparently they are connect to zoom value and image’s resolution , and I suppose something they follow values based on pixel.  
But I don’t know how it works exactly, even any specification.
