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/cb51d9ccabdbd0c690f8a1b12025f7c2 to your computer and use it in GitHub Desktop.
Save whaison/cb51d9ccabdbd0c690f8a1b12025f7c2 to your computer and use it in GitHub Desktop.
UI_edit_outside_func3_3_ProgressInterruptingWindowLoopEnd_timeView.mel
/////////////////メインウィンドウの座標取る
int $Main_Window_topLeftCorner[2];
int $Main_Window_Width_Height[2];
GetWindowPosition();
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;
}
}
}
///////////////////////////////////////////////////
string $window1Name;//ここの外部グローバル変数にアクセスしたい。
string $timeTextControl;
string $timeFeldTextControl;
global proc windowProc001()
{
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:whaison jugem.jpグローバル"
-topLeftCorner $Window_Top $Window_Left
-widthHeight 410 100`;
columnLayout;
$timeTextControl = `text -label $startdayTimeText`;
$timeFeldTextControl = `textField -width 300 -insertionPosition 0 -insertText $startdayTimeText $timeTextControl`;
//button -label "OK" -command ("deleteUI "+$window1Name);
button -label "closeWindowName()" -command "closeWindowName()";
button -label "progressBarGo()" -command "progressBarGo()";
button -label "MainProgressInterruptingWindowLoopEnd()" -command "MainProgressInterruptingWindowLoopEnd()";
showWindow $window1Name;
}
windowProc001();
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;
}
print("02:whaison jugem.jpグローバル $window1Name="+$window1Name+"\n");
//呼ばれる用の関数
global proc closeWindowName(string $closeWindowNameStr)
{
global string $window1Name;//外部グローバルの変数とってくる。
//deleteUI $window1Name;
deleteUI $closeWindowNameStr;
//window002();
}
///////////////////////////////////////////////////////////////////////////////////////////////
// Create a custom progressBar in a windows ...
string $myProgressBarWindow;
string $progressControl;
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:melリファレンスの「progressBar」サンプル"
-iconName "Short Name"
-topLeftCorner $progressBarWindow_Top $progressBarWindow_Left
-widthHeight 400 110`;
columnLayout;
global string $progressControl;
$progressControl = `progressBar -maxValue 10 -width 300`;
button -label "Make Progress!" -command ("progressBar -edit -step 1 " + $progressControl);
button -label "closeAndWindow002" -command "closeAndWindow002()";
button -label "progressBarGo()" -command "progressBarGo()";
button -label "MainProgressInterruptingWindowLoopEnd()" -command "MainProgressInterruptingWindowLoopEnd()";
showWindow $myProgressBarWindow;
}
myProgressBarWindowProc();
print("03:melリファレンスの「progressBar」サンプル $myProgressBarWindow="+$myProgressBarWindow+"\n");
int $progressBarGoCount = 0;
global proc progressBarGo()
{
//別ウィンドウ
//$myProgressBarWindowのプログレスを進める。 $progressControl を使う
global string $progressControl;
progressBar -edit -step 1 $progressControl;
//$myProgressBarWindowのサイズを大きくしていく。 でかくなるけど 白くなっちゃう
//window -edit -widthHeight $width $height $myProgressBarWindow;
}
//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:
print("$MainProgressInterrupting... $i="+$i+"\n");
///////////////////////メインのプログレスバーを動かします。 increases the Main progress bar//////////////////////
//ルートループだと進まないprogressBar -edit -step 1 $gMainProgressBar; // increases the progress bar
MainProgressInterruptingWindowLoopStepOne();
/////////時間表示更新///////////////
timeCount();
////////////////////////////////
break;
case 999:
print("$MainProgressInterrupting... $i="+$i+" 終了っす。 \n");
progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
break;
default:
break;
}
//サブループ
// here goes you code
///////////////////////////////////////////////
for($c=0; $c < 101; $c++)
{
int $debugPrintBool=0;
switch($c)
{
case 10:
case 20:
case 30:
case 40:
case 50:
case 60:
case 70:
case 80:
case 90:
$debugPrintBool=1;
//print("$MainProgressInterrupting...="+$gMainProgressBar+" $c="+$c+"\n");
//print("code... $c="+$c+"\n");
print($c);
///////////////////////メインのプログレスバーを動かします。 increases the Main progress bar//////////////////////
//うごかないprogressBar -edit -step 1 $gMainProgressBar; // increases the progress bar
/////////////////////////////////////////////////////////////////////////
break;
case 100:
$debugPrintBool=2;
print(">>> code... $c="+$c+" 終わったよ"+"\n");
//ループのループ内ここだといい具合にすすむ。
progressBar -edit -step 1 $gMainProgressBar; // increases the progress bar
//MainProgressInterruptingWindowLoopStepOne();
//progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
//子(チャイルド)のループをとめる。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++)
////////////////////////////////////////////
}//for($i=0; $i < $maxPBar; $i++)
global proc MainProgressInterruptingWindowLoopStepOne()
{
print("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 -endProgress $gMainProgressBar;
//子供のプログレスバーウィンドウを進ませる。
progressBarGo();
}
global proc MainProgressInterruptingWindowLoopEnd()
{
//progressBar -edit -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done
global string $gMainProgressBar;
progressBar -edit -endProgress $gMainProgressBar;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment