View Full Version : Multiple playblast in a single file

12-29-2010, 01:49 PM
Hi all,

I have two questions..

Can specify the camera from which we need the playblast through MEL ?

Is there any way to playblast from different cameras as a single file through MEL ?

Thanks in advance..!!:)

01-04-2011, 06:09 PM
yes, and yes.

The full explanation is rather long, though, but basicly you can list all cameras and i.e. based on the existance of a camera named "shotCam" in the scene have that appear at the top in a drop down menu in your playblast window.

There, you can select whichever camera you want to playblast from.
Then, the script stores the name of whichever camera is currently looked through, then temporarily changes the active camera to whatever was selected from the dropdown list, does the playblast, and then changes back to the originally active camera.

As for multiple 'takes' into one file, you have to render to image sequences. Set and store the name of the image sequence (or just set it, but create a lookup to determine if that sequence exists already for the next 'take', then playblast the new range using i.e. another camera and overwrite the same sequence (not actually overwriting, but rather appending to it) and through your script rather than use the -v flag (to view using fcheck) launch fcheck as a new command using the full range (first frame of previous 'take' to last frame of new 'take).

Sorry, badly written, but it is quite a task and really deserves a long explanation. I'll see if I can put together something and put it on my blog along with an explanation.

erm... oooor you could just make a new camera, parent constraint it to your cameras and animate parent constraints (also keyframing the focal length to match the different cameras) for the 'cuts'... -probably the easiest..

01-04-2011, 06:38 PM
Thanks a lot pixelranger got the idea ..

that cut cam method using constrain has been applied..and got worked..!!

but can u plz explain how the active camera can be changed through mel and to make that appear in a new model panel ..!!

and the play blast should render that model panel..


01-04-2011, 07:56 PM
Here's a small example. Note that this is just one way of implementing it in a playblast script.
getPanel, modelPanel and lookThroughModelPanel are the commands you are searching for.

//get the current view pane
string $pane = `getPanel -wf`;
string $panelType = `getPanel -typeOf $pane`;

// if currently active panel is not the viewport, but rather, say, the Outliner or Graph Editor etc
if ($panelType != "modelPanel"){
$pane = "modelPanel4";

// store the original camera
string $origPaneCam = `modelPanel -q -camera $pane`;

// Figure out which camera to use in case you have a
// window with a drop down menu containing cameras
if (`checkBox -q -v playBlastCamCheckBox`){
$playblastCam = `optionMenuGrp -q -v playBlastCamOptions`;
$playblastCam = $origPaneCam;

//make sure we're looking through the playblasting cam
lookThroughModelPanel $playblastCam $pane;

// do the actual playblast. There are many ways to fetch the $startFrame, $endFrame,
// $width, $height etc so I won't go through that. Toooooo looong... :)
// But note the $fileName variable that holds the filepath to your previously created
// playblast
int $viewFullRange = `checkBox -q -v viewFullRangeCheckBox`;
if ($viewFullRange == 0){
playblast -startTime $startFrame -endTime $endFrame -format image -filename $fileName -forceOverwrite -clearCache 1 -viewer $view -showOrnaments $showOrnaments -fp 4 -percent 100 -widthHeight $width $height;
playblast -startTime $startFrame -endTime $endFrame -format image -filename $fileName -forceOverwrite -clearCache 1 -viewer 0 -showOrnaments $showOrnaments -fp 4 -percent 100 -widthHeight $width $height;

float $min = $firstFrameOfPreviouslyCreatedPlayblast;
if ($startFrame<$min)
$min = $startFrame;
float $max = $lastFrameOfPreviouslyCreatedPlayblast;
if ($endFrame>$max)
$max = $endFrame;

// note fcheck's frame padding formatting, also "iff" can be replaced by whatever image format you're using.
string $fcheckCmd = ("fcheck -n " + $min + " " + $max + " 1 \"" + $fileName + ".@@@@.iff\"");
system $fcheckCmd;

//restore the original camera in the view pane
lookThroughModelPanel $origPaneCam $pane;

The list of cameras and the drop down menu can be created like this:

string $cameraShapes[] = `ls -type "camera"`;

// We'll declare a couple of empty arrays. They're declared with
// curly brachets to force them to be (re)declared as empty.
string $cameras[] = {};
string $otherCameras = {}
string $playblastCams[] = {};

for ($cameraShape in $cameraShapes){
if (`getAttr ($cameraShape + ".renderable")`){
select -r $cameraShape;
string $cameraTransform[] = `pickWalk -d up`; // for some weird reason, the pickwalk command returns an array.
$cameras[size($cameras)] = $cameraTransform[0];

for ($camera in $cameras){
// based on the premise that you usually name your
// rendering cameras "someShotNameOrNumber_shotCam"
// we can force this camera to appear at the top of
// the list:
int $anyShotCam=0;
for ( $i = 0; $i < size($cameras); $i++ ){
if ($anyShotCam == 0){
//check if this camera has "shotCam" in its name
$anyShotCam = `gmatch "*shotCam*" $cameras[$i]`;
if ( $anyShotCam == 1){ // if match found start camera list with this one
$playblastCams[0] = $cameras[$i];
//and remove it from the cameras list so it doesn't appear twice
$otherCameras = stringArrayRemove($cameras[$i], $cameras);

// if the $otherCameras array is still empty it means that no shotCam was found
// so we'll create the $playBlastCams array from the original $cameras array
if (!`size($otherCameras){
for ($camera in $cameras){
$playBlastCams[size($playBlastCams)] = $camera;
// However if a shotCam WAS found, we'll build the rest of the $playBlastCams
// array from the $otherCameras array.
for ($camera in $otherCameras){
$playBlastCams[size($playBlastCams)] = $camera;

// And now we can build the drop down menu using the optionMenuGrp command
optionMenuGrp -en 1 -l " " -cw 1 20 -cw 2 180 -cal 1 "right" playBlastCamOptions;
for ( $camera in $playBlastCams ){
menuItem -label $camera;

This was hastily put together and since I can't easily debug such a small part of a potentially large script it probably contains a lot of syntax errors.
But I hope I got the logic/idea across.
It can probably be done MUCH more elegantly, but I just brute forced my way as I was typing, so please excuse any overly complicated ways of i.e. putting together the arrays... hehe

I'll probably wake up in the middle of tonight and slam my forehead.. :)

01-04-2011, 08:19 PM
Actually, if you are working with multiple cameras you might want to have the last used camera on top of the pull down list....

If so, then you can store an option variable containing the camera name, so the next time you run the playblast thingy it will show you what camera you used the last time.
Also, this will be remembered the next time you open Maya which is good if you want to go home and sleep on it.. :)

So just before playblasting, store the active camera in an optionVar:

// look at which camera is used:
string $whichPlayBlastCam = `optionMenuGrp -q -v playBlastCamOptions`;

// And store it in the optionVar:
optionVar -stringValue playblastLastCam $whichPlayBlastCam;

And then, when constructing the window (which I like to do last), search for this optionVar before building the pull down menu (after finding the $cameras array):

string $lastUsedCamera = "";

// If optionVar exists, check its value:
if (`optionVar -ex playblastLastCam`){
$lastUsedCamera = `optionVar -q playblastLastCam`;

if ($lastUsedCamera != ""){
// Check if the stored camera exists in the current scene file
if (`objExists $lastUsedCamera`){
$playBlastCams[0] = $lastUsedCamera;
$otherCameras = stringArrayRemove($lastUsedCamera, $cameras);

... and then fill the $playBlastCams array with either the elements in the $cameras array or the $otherCameras array. And then build the pull down menu.

01-04-2011, 08:27 PM
Again..a handfull of thanks Pixelranger I will work on this....!!! :)

01-04-2011, 09:22 PM
pixel ranger... i visited your website and portfolio....superb works..gr8..yaar !! (means gud friend in India) :)

CGTalk Moderation
01-04-2011, 09:22 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.