# Query currently active viewport camera

**URL:** https://forum.highend3d.com/t/query-currently-active-viewport-camera/160101
**Category:** Maya
**Tags:** maya-boards, python
**Created:** [May 22, 2019, 3:10pm UTC](https://forum.highend3d.com/t/query-currently-active-viewport-camera/160101 "2019-05-22T15:10:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lala\_ghost](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/l/a698b9/32.png) [@lala\_ghost](https://forum.highend3d.com/u/lala_ghost)
#### Post date: [May 22, 2019, 3:10pm UTC](https://forum.highend3d.com/t/query-currently-active-viewport-camera/160101/1 "2019-05-22T15:10:44Z")

</div>

How do I query the current active camera in the viewport by code?  
So the camera you currently see the viewport through?

---

<div class="post-metadata">

### Author: ![eduardo-chavez](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/d6d6ee/32.png) [@eduardo-chavez](https://forum.highend3d.com/u/eduardo-chavez)
#### Post date: [May 26, 2019, 4:59pm UTC](https://forum.highend3d.com/t/query-currently-active-viewport-camera/160101/2 "2019-05-26T16:59:31Z")

</div>

Hi! Get pannel whit focus in mel

---

<div class="post-metadata">

### Author: ![brianhoard](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brianhoard](https://forum.highend3d.com/u/brianhoard)
#### Post date: [May 31, 2019, 10:12pm UTC](https://forum.highend3d.com/t/query-currently-active-viewport-camera/160101/3 "2019-05-31T22:12:30Z")

</div>

It’s a little tricky because if you move your mouse away from the active window, say try to run this from the script editor, your focus windows changes. But this does work if you make it a shelf button. Clicking in the viewport you want to make active, then clicking on this as a button will return your active camera. What are you planning to do with this? Just wondering if you need more code to select the camera, or what?  
//Put this code on a shelf button to return the active camera name.  
modelPanel -q -cam `getPanel -withFocus`;

---

<div class="post-metadata">

### Author: ![system](https://forum.highend3d.com/user_avatar/forum.highend3d.com/system/32/59311_2.png) [@system](https://forum.highend3d.com/u/system)
#### Post date: [August 18, 2019, 3:10am UTC](https://forum.highend3d.com/t/query-currently-active-viewport-camera/160101/4 "2019-08-18T03:10:45Z")

</div>

This topic was automatically closed after 87 days. New replies are no longer allowed.
