PDA

View Full Version : Current cam


nottoshabi
02-04-2011, 02:44 AM
I'm trying to query the current cam. I want to be able to select the cam that is in the main view port throw mel. So for example if some one wants to play blast from cam1 and that is the only cam that is in the view port. How can I query that? How can I write throw mel, hey this is the cam I'm looking throw what is the name of this cam?

Cause I would like to select that cam and turn the resolution gate on and off. Throw mel.

pritishd
02-04-2011, 02:51 AM
I'm trying to query the current cam. I want to be able to select the cam that is in the main view port throw mel. So for example if some one wants to play blast from cam1 and that is the only cam that is in the view port. How can I query that? How can I write throw mel, hey this is the cam I'm looking throw what is the name of this cam?

Cause I would like to select that cam and turn the resolution gate on and off. Throw mel.

modelPanel -q -cam `getPanel -underPointer`;

or

modelPanel -q -cam `getPanel -withFocus`;

nottoshabi
02-04-2011, 03:05 AM
modelPanel -q -cam `getPanel -withFocus`;
// Error: modelPanel: Object 'scriptEditorPanel1' not found. //


I get this error when I try both lines.

pritishd
02-04-2011, 03:26 AM
modelPanel -q -cam `getPanel -withFocus`;
// Error: modelPanel: Object 'scriptEditorPanel1' not found. //


I get this error when I try both lines.

For the first on,e make sure when you are executing the script, your mouse pointer is on the panel you want the playblast from.

On the second one, make sure you have the panel selected/focused. For this you may have run it as a hotkey or put it as shelf button.

pixelranger
02-04-2011, 11:21 AM
The problem is that if you run it from the script Editor, it is the Script Editor that has focus.
Just make sure the viewport is active (blue outline) when you run it. This won't be a problem when running from a shelf button.

Another thing you can do, is force it when exceptions (dodgy, if you're using multiple views a lot):
string $curPane = `getPanel -withFocus`;
if ($curPane == "scriptEditorPanel1"){
$curPane = "modelPanel4";
}
string $cam = `modelPanel -q -cam $curPane`;

EJ
02-04-2011, 06:21 PM
try this with the api, you don't have to be in focus...

import maya.cmds as cmds
import maya.OpenMaya as OpenMaya
import maya.OpenMayaUI as OpenMayaUI

view = OpenMayaUI.M3dView.active3dView()
cam = OpenMaya.MDagPath()
view.getCamera(cam)
camPath = cam.fullPathName()
print camPath

nottoshabi
02-04-2011, 09:25 PM
Thanks guys. I got it working.

CGTalk Moderation
02-04-2011, 09:25 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.