global proc playBlastWin(){
if (`window -ex playBlastWin`)
deleteUI playBlastWin;
window -t "拍屏窗口 beta 0.1" playBlastWin;
columnLayout -enable 1 -cw 300 -h 200 -adj 1 -columnAlign "left" mainCol;
textField pathTF;
button -l "存取路径" -c "getPath";
button -l "拍屏" -c "playblastProc";
text -h 20 -l "使用说明:";
text -h 20 -l "第一步:设置渲染尺寸大小";
text -h 20 -l "第二步:选择'存取路径'按钮";
text -h 20 -l "第三步:在弹出的窗口中指定拍屏路径";
text -h 20 -l "提示:不必指定拍屏格式,拍屏会自动存为AVI格式";
text -h 20 -l "第四步:确定视图最大化并为被激活状态执行'拍屏'命令";
text -h 20 -l "注意:";
text -h 20 -l "由于脚本尚未测试阶段,在拍屏后会出现MAYA其他窗口无法打开的现象。";
text -h 20 -l "当出现以上现象时请源化'resetMayaWindows'脚本就可修复以上问题";
showWindow playBlastWin;
}
global proc getPath()
{
string $path = `fileDialog -m 1`;
textField -e -tx $path pathTF;
}
global proc playblastProc(){
string $path = `textField -q -tx pathTF`;
int $resolutionWidth = `getAttr "defaultResolution.width"`;
int $resolutionHeight = `getAttr "defaultResolution.height"`;
string $modelPanel = `getPanel -withFocus`;
string $camera = `modelEditor -query -camera $modelPanel`;
setAttr ($camera + ".displayResolution") 1;
setAttr ($camera + ".displaySafeAction") 1;
zwHeadsUpDisplay;
playblast -format movie
-filename $path
-forceOverwrite
-clearCache 1
-viewer 1
-showOrnaments 1
-fp 4
-percent 100
-compression none
-widthHeight $resolutionWidth $resolutionHeight;
removeHUD;
evalDeferred("source initAfter.mel");
}
//=========================================================================
//
// Python Source File -- Created with SAPIEN Technologies PrimalScript 4.1
//
// NAME: zwHeadsUpDisplay.mel
//
//AUTHOR: Original author is HuangZhongwei @ 31F Shenzhen , P.R.China
// hanjiang , ustc
// DATE : 8/26/2007
//
// COMMENT: This script is originally written by HuangZhongwei @ 31F Shenzhen, I modified it a little bit to make it up and
// running under Maya 8.5
//
//=========================================================================
// 640*480
global proc string zwHeadsUpDisplayGlobalResolution()
{
int $resolutionWidth = `getAttr "defaultResolution.width"`;
int $resolutionHeight = `getAttr defaultResolution.height`;
string $str = $resolutionWidth + "*" + $resolutionHeight;
return $str;
}
//get current user
global proc string zwHeadsUpDisplayUser()
{
string $buf[];
//clear $buf;
string $user = "";
string $name = `file -query -sceneName`;
int $sizeName = `tokenize $name "/" $buf`;
//string $filename = $buf[size($buf)-5];
if (size($name) > 0)
{
string $filename = $buf[size($buf)-5];
return $filename;}
else {
return "NONE";
}
}
global proc string zwHeadsUpDisplayUser1()
{
string $cmd = "date /t";
chdir "C:";
string $date = `system $cmd`;
$date = `substring $date 1 10`;
$cmd = "time";
string $time = `system $cmd`;
$time = `substring $time 22 26`;
string $dateTime = strip($date) + " " + $time;
return $dateTime;
}
global proc float zwHeadsUpDisplayStart()
{
float $start;
if (`optionVar -query playblastUseStartEnd`)
$start = `optionVar -q playblastStartTime`;
else{
$start = `playbackOptions -q -minTime`;}
return $start;
}
global proc float zwHeadsUpDisplayEnd()
{
float $end;
if (`optionVar -query playblastUseStartEnd`)
$end = `optionVar -q playblastEndTime`;
else
$end = `playbackOptions -q -maxTime`;
return $end;
}
global proc int zwHeadsUpDisplayTotal()
{
float $start = `zwHeadsUpDisplayStart`;
float $end = `zwHeadsUpDisplayEnd`;
int $total = $end - $start + 1;
return $total;
}
/*
global proc string zwHeadsUpDisplayFrame()
{
float $currentTime = `currentTime -query`;
float $start = `zwHeadsUpDisplayStart`;
int $total = `zwHeadsUpDisplayTotal`;
string $frame = $currentTime + " (" + ($currentTime - $start + 1) + "/" + $total + ")";
return $frame;
}
*/
global proc string zwHeadsUpDisplayFrame()
{
float $currentTime = `currentTime -query`;
return $currentTime;
}
global proc string zwHeadsUpDisplaySequence()
{
float $currentTime = `currentTime -query`;
float $start = `zwHeadsUpDisplayStart`;
int $total = `zwHeadsUpDisplayTotal`;
int $sequence = $currentTime - $start + 1;//) + "/" + $total;
string $str = $sequence + "/" + $total;
int $size = size("" + $total) - size("" + $sequence);
for ($i=0; $i<$size; $i++)
$str = "0" + $str;
return $str;
}
global proc float zwHeadsUpDisplayFocalLength(string $camera)
{
float $focalLength;
if (`objExists $camera`)
$focalLength = `getAttr ($camera + ".focalLength")`;
return $focalLength;
}
global proc string zwHeadsUpDisplayCamera()
{
string $modelPanel = `getPanel -withFocus`;
string $camera = `modelEditor -query -camera $modelPanel`;
string $cameraName = `basenameEx $camera`;
return $cameraName;
}
// zwHeadsUpDisplayRemove();
global proc zwHeadsUpDisplayRemove(int $mode)
{
// $mode =0 ---> rebuild original HUD
global string $zwHeadsUpDisplay;
string $buf[] = `headsUpDisplay -listHeadsUpDisplays`;
for ($headsUpDisplay in $buf)
headsUpDisplay -remove $headsUpDisplay;
$buf = `ls -type "expression" "zwHeadsUpDisplay*"`;
if (size($buf))
delete $buf;
// dunno why but if u don't delay the execution of initAfter.mel
// maya 8.5 will crash...
if ($mode==0){
evalDeferred("source initAfter.mel");
catch (`eval $zwHeadsUpDisplay`);
$zwHeadsUpDisplay = "";
}
}
global proc int zwHeadsUpDisplay()
{
global string $zwHeadsUpDisplay;
float $space = 84.0;
zwHeadsUpDisplayRemove(1);
// get camera
string $modelPanel = `getPanel -withFocus`;
if (`getPanel -typeOf $modelPanel` != "modelPanel")
error "Please select the view you want to playblast";
string $camera = `modelEditor -query -camera $modelPanel`;
string $cameraName = `basenameEx $camera`;
if (`nodeType $camera` != "camera")
{
string $buf[] = `listRelatives -fullPath -shapes $camera`;
$camera = $buf[0];
}
// if resolution gate is displayed , the rez will show at section 2
// so we can temporarily disable it and store the command in a global var
// when we remove custom HUD after playblast, we can set it back
if (`getAttr ($camera + ".displayResolution")`)
{
setAttr ($camera + ".displayResolution") 0;
$zwHeadsUpDisplay += "setAttr " + $camera + ".displayResolution true;\n";
}
headsUpDisplay -section 2 -block 0 -atr -labelFontSize "large" -dataFontSize "large" -command "zwHeadsUpDisplayGlobalResolution" zwHeadsUpDisplayGlobalResolution;
headsUpDisplay -section 4 -block 0 -labelFontSize "large" -dataFontSize "large" -blockAlignment "right" -event "timeChanged" -command "zwHeadsUpDisplayUser1" zwHeadsUpDisplayUser1;
headsUpDisplay -section 0 -block 0 -labelFontSize "large" -dataFontSize "large" -c "zwHeadsUpDisplayCamera" -atr zwHeadsUpDisplayCameraNames;
headsUpDisplay -section 4 -block 1 -labelFontSize "large" -dataFontSize "large" -blockAlignment "right" -label "Focal Length:" -event "timeChanged" -command ("zwHeadsUpDisplayFocalLength \"" + $camera + "\"") zwHeadsUpDisplayFocalLength;
headsUpDisplay -section 5 -block 1 -labelFontSize "large" -dataFontSize "large" -label "frame:" -event "timeChanged" -command "zwHeadsUpDisplayFrame" zwHeadsUpDisplayFrame;
headsUpDisplay -section 7 -block 1 -labelFontSize "large" -dataFontSize "large" -label "sequence:" -event "timeChanged" -command "zwHeadsUpDisplaySequence" zwHeadsUpDisplaySequence;
headsUpDisplay -section 5 -block 0 -labelFontSize "large" -dataFontSize "large" -label "start:" -event "timeChanged" -command "zwHeadsUpDisplayStart" zwHeadsUpDisplayStart;
headsUpDisplay -section 7 -block 0 -labelFontSize "large" -dataFontSize "large" -label "end:" -event "timeChanged" -command "zwHeadsUpDisplayEnd" zwHeadsUpDisplayEnd;
headsUpDisplay -section 9 -block 0 -labelFontSize "large" -dataFontSize "large" -blockAlignment "right" -label "total:" -event "timeChanged" -command "zwHeadsUpDisplayTotal" zwHeadsUpDisplayTotal;
headsUpDisplay -section 9 -block 1 -atr -labelFontSize "large" -dataFontSize "large" -label "Project:"-command "zwHeadsUpDisplayUser" zwHeadsUpDisplayUser;
//headsUpDisplay -q -lh;
//headsUpDisplay -rem zwHeadsUpDisplayUser;
// create expressions
string $script = "// Created by Playblast, HuangZhongwei R&D IDMT\n\n";
$script += "headsUpDisplay -refresh zwHeadsUpDisplayFrame;\n";
$script += "headsUpDisplay -refresh zwHeadsUpDisplaySequence;\n";
$script += "headsUpDisplay -refresh zwHeadsUpDisplayFocalLength;";
expression -string $script -name "zwHeadsUpDisplay";
return true;
}
global proc removeHUD()
{
headsUpDisplay -rem zwHeadsUpDisplayGlobalResolution;
//headsUpDisplay -rem zwHeadsUpDisplayGlobalResolution;
headsUpDisplay -rem zwHeadsUpDisplayUser1;
headsUpDisplay -rem zwHeadsUpDisplayCameraNames;
headsUpDisplay -remove zwHeadsUpDisplayFocalLength;
headsUpDisplay -rem zwHeadsUpDisplayFrame;
headsUpDisplay -rem zwHeadsUpDisplaySequence;
headsUpDisplay -rem zwHeadsUpDisplayStart;
headsUpDisplay -rem zwHeadsUpDisplayEnd;
headsUpDisplay -rem zwHeadsUpDisplayTotal;
headsUpDisplay -rem zwHeadsUpDisplayUser;
}
playBlastWin();