Home Technical Talk

[MEL] - Check if my active Panel have a Camera

Hello !  :)

I'm trying to get the Camera's name of an active View ( like "persp" or "Camera5" ).

string $activeView = `getPanel -withFocus`;
string $camName = `modelPanel -q -cam $activeView`;
print  $camName;


So far, it works well. But I would like to detect if the focused panel have a working camera, and if not, get the last panel that had focus + a camera.

Ex: I'm working in my [B]Camera5[/B] view, then I got in the GraphEditor, then I select an object in my [B]outliner[/B], I launch the script = return the camera name of [B]Camera5[/B].

Actually, when my active panel doesn't have a camera, I have this type of error:

Error: line 6: modelPanel: Object 'outlinerPanel1' not found.

Is there a way?

Thank you ! hope there is a way


Replies

  • throttlekitty
    Options
    Offline / Send Message
    I don't think Maya keeps a history of panels like that. I think you could set up a scriptJob to track every time a panel is changed, setting $currentPanel to $previousPanel each time. It sounds a bit overkill to have that running all the time though. Perhaps there's a different approach for what you're wanting to script?

    For the error, you'll need an exception for panels that can't have a camera, anything but a modelPanel type.
Sign In or Register to comment.