Query currently active viewport camera

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

Hi! Get pannel whit focus in mel

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`;

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