Zodrac
10-10-2005, 08:54 PM
Ok my objective is to create a window with different tabs. I want different tabs to show depending on which type of light that is selected.
Since i haven't found a way to hide single tabs i have to recreate the window each time i select a new light. My problem is with the scriptjob line that is at the bottom of the 5 mile long code. The code works fine except that the scriptjobs doesn't just run when the selection is changed it keeps on running and running and i don't know why.
Any help would be appriciated.
//Zodrac
//beginglobal procHelp==============================================================================
// PROCEDURE: LightWindow_UI (global)
// ARGUEMENTS: NONE
// RETURN: NONE
// DESCRIPTION: Main procedure. Creates the light board window
//endglobal procHelp================================================================================
global proc LightWindow_UI()
{
//-=Check if window already exists and delete if it does=-
//**************************************************************************************************
if (`window -exists LightWindow`)
deleteUI -window LightWindow;
//**************************************************************************************************
//-=Creating window=-
//**************************************************************************************************
window -title "Light_Board" LightWindow;
//**************************************************************************************************
Tab_UI;
}
//beginglobal procHelp==============================================================================
// PROCEDURE: Tab_UI (global)
// ARGUEMENTS: NONE
// RETURN: NONE
// DESCRIPTION: Creates the tabs depending on whitch type of lights are selected
//endglobal procHelp================================================================================
global proc Tab_UI()
{
//-=Creating formlayout to hold all controls in the window=-
//**************************************************************************************************
string $formLight = `formLayout -numberOfDivisions 100`;
//**************************************************************************************************
//-=Creats a tablayout=-
//**************************************************************************************************
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
//**************************************************************************************************
//-=Places the tab layout=-
//**************************************************************************************************
formLayout -edit
-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0
$formLight;
//**************************************************************************************************
//-=If anything is selected pickwalk down to select it's shape node=-
//**************************************************************************************************
string $nodeList[] = `ls -selection`;
if (size($nodeList)>0)
{
pickWalk -d down;
}
//**************************************************************************************************
//-=Saving all selected node types into $nodeType=-
//**************************************************************************************************
string $nodeList[] = `ls -selection`;
string $nodeType[];
for($i = 0; $i < size($nodeList); $i++)
{
$nodeType[$i] = `nodeType $nodeList[$i]`;
}
//**************************************************************************************************
//-=Filtering out just the light node types and saving them to $lightList=-
//**************************************************************************************************
string $lightList[];
int $i2 = 0;
for($i = 0; $i < size($nodeType); $i++)
{
if ($nodeType[$i] == "ambientLight" || $nodeType[$i] == "directionalLight" || $nodeType[$i] == "pointLight" ||
$nodeType[$i] == "spotLight" || $nodeType[$i] == "areaLight" || $nodeType[$i] == "volumeLight")
{
$lightList[$i2] = $nodeType[$i];
$i2 ++;
}
}
//**************************************************************************************************
//-=Checks which type of lights are selected=-
//**************************************************************************************************
int $generalExist = 0;
int $ambientExist = 0;
int $directionalExist = 0;
int $pointExist = 0;
int $spotExist = 0;
int $areaExist = 0;
int $volumeExist = 0;
int $lightExist[];
for($i = 0; $i < size($lightList); $i++)
{
switch ($lightList[$i])
{
case "ambientLight":
$ambientExist = 1;
break;
case "directionalLight":
$directionalExist = 1;
break;
case "pointLight":
$pointExist = 1;
break;
case "spotLight":
$spotExist = 1;
break;
case "areaLight":
$areaExist = 1;
break;
case "volumeLight":
$volumeExist = 1;
break;
}
}
if ($ambientExist + $directionalExist + $pointExist + $spotExist + $areaExist + $volumeExist > 1)
$generalExist = 1;
$lightExist[0] = $generalExist;
$lightExist[1] = $ambientExist;
$lightExist[2] = $directionalExist;
$lightExist[3] = $pointExist;
$lightExist[4] = $spotExist;
$lightExist[5] = $areaExist;
$lightExist[6] = $volumeExist;
//**************************************************************************************************
//-=Creates all tabs depending on which types of lights are selected=-
//**************************************************************************************************
if ($lightExist[0] == 1)
{
string $generalTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $generalTab "General"
$tabs;
}
if ($lightExist[1] == 1)
{
string $ambientTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $ambientTab "Ambient"
$tabs;
}
if ($lightExist[2] == 1)
{
string $directionalTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $directionalTab "Directional"
$tabs;
}
if ($lightExist[3] == 1)
{
string $pointTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $pointTab "Point"
$tabs;
}
if ($lightExist[4] == 1)
{
string $spotTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $spotTab "Spot"
$tabs;
}
if ($lightExist[5] == 1)
{
string $areaTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $areaTab "Area"
$tabs;
}
if ($lightExist[6] == 1)
{
string $volumeTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $volumeTab "Volume"
$tabs;
}
//**************************************************************************************************
showWindow($lightList);
}
//beginglobal procHelp==============================================================================
// PROCEDURE: ShowWindow (global)
// ARGUEMENTS: NONE
// RETURN: NONE
// DESCRIPTION: Shows the window if any lights are selected
//endglobal procHelp================================================================================
global proc showWindow(string $lightList[])
{
//-=Specifies the window format and shows it=-
//**************************************************************************************************
window -edit -topLeftCorner 131 3 -sizeable false -width 350 -height 425 -retain LightWindow;
showWindow;
//**************************************************************************************************
}
global proc UpdateWindow()
{
if (`window -exists LightWindow`)
LightWindow_UI;
}
LightWindow_UI;
int $selectionJob = `scriptJob -event "SelectionChanged" UpdateWindow`;
Since i haven't found a way to hide single tabs i have to recreate the window each time i select a new light. My problem is with the scriptjob line that is at the bottom of the 5 mile long code. The code works fine except that the scriptjobs doesn't just run when the selection is changed it keeps on running and running and i don't know why.
Any help would be appriciated.
//Zodrac
//beginglobal procHelp==============================================================================
// PROCEDURE: LightWindow_UI (global)
// ARGUEMENTS: NONE
// RETURN: NONE
// DESCRIPTION: Main procedure. Creates the light board window
//endglobal procHelp================================================================================
global proc LightWindow_UI()
{
//-=Check if window already exists and delete if it does=-
//**************************************************************************************************
if (`window -exists LightWindow`)
deleteUI -window LightWindow;
//**************************************************************************************************
//-=Creating window=-
//**************************************************************************************************
window -title "Light_Board" LightWindow;
//**************************************************************************************************
Tab_UI;
}
//beginglobal procHelp==============================================================================
// PROCEDURE: Tab_UI (global)
// ARGUEMENTS: NONE
// RETURN: NONE
// DESCRIPTION: Creates the tabs depending on whitch type of lights are selected
//endglobal procHelp================================================================================
global proc Tab_UI()
{
//-=Creating formlayout to hold all controls in the window=-
//**************************************************************************************************
string $formLight = `formLayout -numberOfDivisions 100`;
//**************************************************************************************************
//-=Creats a tablayout=-
//**************************************************************************************************
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
//**************************************************************************************************
//-=Places the tab layout=-
//**************************************************************************************************
formLayout -edit
-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0
$formLight;
//**************************************************************************************************
//-=If anything is selected pickwalk down to select it's shape node=-
//**************************************************************************************************
string $nodeList[] = `ls -selection`;
if (size($nodeList)>0)
{
pickWalk -d down;
}
//**************************************************************************************************
//-=Saving all selected node types into $nodeType=-
//**************************************************************************************************
string $nodeList[] = `ls -selection`;
string $nodeType[];
for($i = 0; $i < size($nodeList); $i++)
{
$nodeType[$i] = `nodeType $nodeList[$i]`;
}
//**************************************************************************************************
//-=Filtering out just the light node types and saving them to $lightList=-
//**************************************************************************************************
string $lightList[];
int $i2 = 0;
for($i = 0; $i < size($nodeType); $i++)
{
if ($nodeType[$i] == "ambientLight" || $nodeType[$i] == "directionalLight" || $nodeType[$i] == "pointLight" ||
$nodeType[$i] == "spotLight" || $nodeType[$i] == "areaLight" || $nodeType[$i] == "volumeLight")
{
$lightList[$i2] = $nodeType[$i];
$i2 ++;
}
}
//**************************************************************************************************
//-=Checks which type of lights are selected=-
//**************************************************************************************************
int $generalExist = 0;
int $ambientExist = 0;
int $directionalExist = 0;
int $pointExist = 0;
int $spotExist = 0;
int $areaExist = 0;
int $volumeExist = 0;
int $lightExist[];
for($i = 0; $i < size($lightList); $i++)
{
switch ($lightList[$i])
{
case "ambientLight":
$ambientExist = 1;
break;
case "directionalLight":
$directionalExist = 1;
break;
case "pointLight":
$pointExist = 1;
break;
case "spotLight":
$spotExist = 1;
break;
case "areaLight":
$areaExist = 1;
break;
case "volumeLight":
$volumeExist = 1;
break;
}
}
if ($ambientExist + $directionalExist + $pointExist + $spotExist + $areaExist + $volumeExist > 1)
$generalExist = 1;
$lightExist[0] = $generalExist;
$lightExist[1] = $ambientExist;
$lightExist[2] = $directionalExist;
$lightExist[3] = $pointExist;
$lightExist[4] = $spotExist;
$lightExist[5] = $areaExist;
$lightExist[6] = $volumeExist;
//**************************************************************************************************
//-=Creates all tabs depending on which types of lights are selected=-
//**************************************************************************************************
if ($lightExist[0] == 1)
{
string $generalTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $generalTab "General"
$tabs;
}
if ($lightExist[1] == 1)
{
string $ambientTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $ambientTab "Ambient"
$tabs;
}
if ($lightExist[2] == 1)
{
string $directionalTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $directionalTab "Directional"
$tabs;
}
if ($lightExist[3] == 1)
{
string $pointTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $pointTab "Point"
$tabs;
}
if ($lightExist[4] == 1)
{
string $spotTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $spotTab "Spot"
$tabs;
}
if ($lightExist[5] == 1)
{
string $areaTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $areaTab "Area"
$tabs;
}
if ($lightExist[6] == 1)
{
string $volumeTab = `rowColumnLayout -numberOfColumns 2`;
setParent ..;
tabLayout -edit
-tabLabel $volumeTab "Volume"
$tabs;
}
//**************************************************************************************************
showWindow($lightList);
}
//beginglobal procHelp==============================================================================
// PROCEDURE: ShowWindow (global)
// ARGUEMENTS: NONE
// RETURN: NONE
// DESCRIPTION: Shows the window if any lights are selected
//endglobal procHelp================================================================================
global proc showWindow(string $lightList[])
{
//-=Specifies the window format and shows it=-
//**************************************************************************************************
window -edit -topLeftCorner 131 3 -sizeable false -width 350 -height 425 -retain LightWindow;
showWindow;
//**************************************************************************************************
}
global proc UpdateWindow()
{
if (`window -exists LightWindow`)
LightWindow_UI;
}
LightWindow_UI;
int $selectionJob = `scriptJob -event "SelectionChanged" UpdateWindow`;
