Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whaison/62cbfda460d679357752a76360f63e5c to your computer and use it in GitHub Desktop.
Save whaison/62cbfda460d679357752a76360f63e5c to your computer and use it in GitHub Desktop.
UI_edit_outside_func3_5_v00100_ProgressInterruptingWindowLoopEnd_timeView_bugfix_good_Refactoring.mel
/////////////////メインウィンドウの座標取る
int $Main_Window_topLeftCorner[2];
int $Main_Window_Width_Height[2];
///////////////////////////////////////////////////
string $window1Name;//ここの外部グローバル変数にアクセスしたい。
string $timeTextControl;
string $timeFeldTextControl;
//////////////////////////////
string $scrollFieldControl;
string $Log;
///////////////////////////
string $myProgressBarWindow_2;
string $progressControl_2;
////////////////////////////////
/////////////////////////////////
string $myProgressBarWindow;
string $progressControl;
int $progressBarGoCount;
////////////////////////////////////////////////////////////////
//////////////////////////Main Loop/////////////////////////////
////////////////////////////////////////////////////////////////
workspaces_all_do_method_010_move_value_zero_start_progress_v002();
global proc workspaces_all_do_method_010_move_value_zero_start_progress_v002(){
/////////////////メイン関数用セットアップ////////////////////////////////
GetWindowPosition();
global int $progressBarGoCount;
$progressBarGoCount = 0;
myProgressBarWindowProc();
global string $myProgressBarWindow;
print("010:progressBar Window $myProgressBarWindow="+$myProgressBarWindow+"\n");
LogWindowProc001();
global string $window1Name;
print("020:Log Window $window1Name="+$window1Name+"\n");
//////////////////メイン関数用セットアップ終わり//////////////////////////////
//SVENNEVE.COM 「Maya progressBar and interrupting a script loop」
//////////////////メインウィンドウのプログレスバーでしか使えない機能///////////////////////
global string $gMainProgressBar;
int $maxPBar = 10000;
$maxPBar = 1000;
//Mayaのメインウィンドウ左下のプログレスバーをスタートする。
progressBar -edit -beginProgress -isInterruptable 1 -max $maxPBar $gMainProgressBar;
for($i=0; $i < $maxPBar; $i++)
{
//メインループ
if(`progressBar -query -isCancelled $gMainProgressBar`)
{
print("キャンセルされました。");
progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
break;
}
int $i_debugPrintBool=0;
switch($i)
{
case 100:
case 200:
case 300:
case 400:
case 500:
case 600:
case 700:
case 800:
case 900:
case 990:
Logger("$MainProgressInterrupting... $i="+$i+"\n");
///////////////////////メインのプログレスバーを動かします。 increases the Main progress bar//////////////////////
//ルートループだと進まないprogressBar -edit -step 1 $gMainProgressBar; // increases the progress bar
/////////時間表示更新///////////////
timeCount();
////////////////////////////////
//子供のプログレスバーウィンドウを進ませる。
progressBarGo();
break;
case 999:
Logger("$MainProgressInterrupting... $i="+$i+" 終了っす。 \n");
//progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
MainProgressInterruptingWindowLoopEnd();
break;
default:
break;
}
//サブループ
// here goes you code
///////////////////////////////////////////////Sub Loop Start
MainWindowProgressSubLoop();
////////////////////////////////////////////Sub Loop End
}//for($i=0; $i < $maxPBar; $i++)
}
////////////////////////////////////////////////////////////////
///////////////////////Main Loop END//////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//////////////////////Sub Loop Start//////////////////////////
////////////////////////////////////////////////////////////////
global proc MainWindowProgressSubLoop()
{
global string $gMainProgressBar;
//サブループ
// here goes you code
///////////////////////////////////////////////
for($c=0; $c < 1001; $c++)
{
int $debugPrintBool=0;
switch($c)
{
case 100:
case 200:
case 300:
case 400:
case 500:
case 600:
case 700:
case 800:
case 900:
case 950:
$debugPrintBool=1;
//print("$MainProgressInterrupting...="+$gMainProgressBar+" $c="+$c+"\n");
//print("code... $c="+$c+"\n");
Logger($c);
///////////////////////メインのプログレスバーを動かします。 increases the Main progress bar//////////////////////
//うごかないprogressBar -edit -step 1 $gMainProgressBar; // increases the progress bar
/////////////////////////////////////////////////////////////////////////
break;
case 1000:
$debugPrintBool=2;
Logger(">>> code... $c="+$c+" 終わったよ"+"\n");
//ループのループ内ここだといい具合にすすむ。
//progressBar -edit -step 1 $gMainProgressBar; //OK increases the progress bar
MainProgressInterruptingWindowLoopStepOneOnly();
//子(チャイルド)のループをとめる。for($c=0; $c < 101; $c++)
break;
//親(ルート)のループをとめる。for($i=0; $i < $maxPBar; $i++)
break;
break;
default:
break;
}// switch($c)
}// code for($c=0; $c < 101; $c++)
////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////
////////////////////////Sub Loop End///////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////Inside StepOne ////////////////////////////
////////////////////////////////////////////////////////////////
global proc MainProgressInterruptingWindowLoopStepOneOnly()
{
Logger("Main StepOne()"+"\n");
//progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
global string $gMainProgressBar;
//別関数からだと進まない
progressBar -edit -step 1 $gMainProgressBar; // increases the progress bar
}
global proc MainProgressInterruptingWindowLoopEnd()
{
MainProgressInterruptingWindowLoopStepOne();
//progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
global string $gMainProgressBar;
progressBar -edit -endProgress $gMainProgressBar;
Logger("MainProgressInterruptingWindowLoopEnd()"+"\n");
//closeSubAllWindow();
LogShowInWindow();
}
////////////////////////////////////////////////////////////////
////////////////////////Inside StepOne End////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////window Proc //////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
global proc myProgressBarWindowProc(){
global int $Main_Window_topLeftCorner[];
global int $Main_Window_Width_Height[];
int $progressBarWindow_Top=$Main_Window_topLeftCorner[0];
int $progressBarWindow_Left=$Main_Window_topLeftCorner[1];
global string $myProgressBarWindow;
$myProgressBarWindow = `window -title "03:progressBar Window"
-iconName "Short Name"
-topLeftCorner $progressBarWindow_Top $progressBarWindow_Left
-widthHeight 500 110`;
columnLayout;
global string $progressControl;
$progressControl = `progressBar -maxValue 10 -width 500`;
button -label "Make Progress!" -command ("progressBar -edit -step 1 " + $progressControl);
button -label ("closeWindowName("+$myProgressBarWindow+")") -command ("closeWindowName($myProgressBarWindow)");
button -label "progressBarGo()" -command "progressBarGo()";
button -label "MainProgressInterruptingWindowLoopEnd()" -command "MainProgressInterruptingWindowLoopEnd()";
showWindow $myProgressBarWindow;
}
global proc progressBarGo()
{
//別ウィンドウ
//$myProgressBarWindowのプログレスを進める。 $progressControl を使う
global string $progressControl;
progressBar -edit -step 1 $progressControl;
//$myProgressBarWindowのサイズを大きくしていく。 でかくなるけど 白くなっちゃう
//window -edit -widthHeight $width $height $myProgressBarWindow;
global string $progressControl_2;
progressBar -edit -step 1 $progressControl_2;
}
///////////////////////////////////////////////////////////////////////Log window start
global proc LogWindowProc001()
{
string $currentDate=`about -currentDate`;
string $currentTime=`about -currentTime`;
string $startdayTimeText=$currentDate+" : "+$currentTime+" : Time Start";
global string $timeTextControl;
global string $timeFeldTextControl;
global int $Main_Window_topLeftCorner[];
global int $Main_Window_Width_Height[];
int $Window_Top=$Main_Window_topLeftCorner[0]+300;
int $Window_Left=$Main_Window_topLeftCorner[1];
global string $window1Name;//外部グローバルの変数とってくる。
$window1Name = `window -title "02:LogWindow"
-topLeftCorner $Window_Top $Window_Left
-widthHeight 500 300`;
columnLayout;
$timeTextControl = `text -label $startdayTimeText`;
$timeFeldTextControl = `textField -width 500 -insertionPosition 0 -insertText $startdayTimeText $timeTextControl`;
/////////////////////////////////////////////////////
global string $Log;
$Log="Start...\n";
global string $scrollFieldControl;
$scrollFieldControl = `scrollField -width 500 -wordWrap true -text $Log`;
global string $progressControl_2;
$progressControl_2 = `progressBar -maxValue 10 -width 500`;
//////////////////////////////////////////////////////
//button -label "OK" -command ("deleteUI "+$window1Name);
button -label ("closeSubAllWindow()") -command ("closeSubAllWindow()");
button -label ("closeWindowName("+$window1Name+")") -command ("closeWindowName($window1Name)");
button -label "progressBarGo()" -command "progressBarGo()";
button -label "MainProgressInterruptingWindowLoopEnd()" -command "MainProgressInterruptingWindowLoopEnd()";
showWindow $window1Name;
}
///////////////////////////////////////////////////////////////////////Log window End
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////window Proc End //////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////Sub Proc //////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
global proc GetWindowPosition()
{
string $windowList[] =`lsUI -windows`;
global int $Main_Window_topLeftCorner[];
global int $Main_Window_Width_Height[];
for($win in $windowList){
if($win == "MayaWindow"){
$Main_Window_topLeftCorner = `window -q -topLeftCorner $win`;
$Main_Window_Width_Height = `window -q -widthHeight $win`;
break;
}
}
}
global proc timeCount()
{
string $currentDate=`about -currentDate`;
string $currentTime=`about -currentTime`;
string $startdayTimeText=$currentDate+" : "+$currentTime+" : Time End";
global string $timeTextControl;
//$timeTextControl = `text -label $startdayTimeText`;
global string $timeFeldTextControl;
//$timeFeldTextControl = `textField -edit -insertionPosition 0 -insertText $startdayTimeText`;
textField -edit -text $startdayTimeText $timeFeldTextControl;
///////////////////////////////
// progressBar -edit -step 1 $progressControl;
}
//呼ばれる用の関数
global proc closeWindowName(string $closeWindowNameStr)
{
global string $window1Name;//外部グローバルの変数とってくる。
global string $myProgressBarWindow;//外部グローバルの変数とってくる。
// closeWindowName($window1Name);
// closeWindowName($myProgressBarWindow);
//deleteUI $window1Name;
print("closeWindowName("+$closeWindowNameStr+")"+"\n");
deleteUI $closeWindowNameStr;
//window002();
}
//呼ばれる用の関数
global proc closeSubAllWindow()
{
global string $window1Name;//外部グローバルの変数とってくる。
global string $myProgressBarWindow;//外部グローバルの変数とってくる。
closeWindowName($window1Name);
closeWindowName($myProgressBarWindow);
//deleteUI $window1Name;
print("closeSubAllWindow()"+"\n");
//deleteUI $closeWindowNameStr;
//window002();
}
global proc Logger(string $str)
{
global string $Log;
$Log= $Log + $str;
}
global proc LogShowInWindow()
{
global string $Log;
global string $scrollFieldControl;
scrollField -edit -text $Log $scrollFieldControl;
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////Sub Proc END//////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment