xcomb
10-27-2006, 10:06 AM
Hi all!
Well i created simple UI that pretty much selects objects in a scene and displays their attributes, i do that for practicing.
So the thing is i was able to select and set keyframes on multiple objects, and list all their attributes into another textScrollList, but when comes to deleting all keyframes i am only able to delete on one selected. This has to do with loops, whcih i can't get the sence.
Take a look all the way in the bottom, i am putting whole script.
Sorry for the mess, i believe there should be two loops to loop first for selected objects, let's say 3 times, and loop to select their attributes, then to use the deletion function.
if(`window -exists mainWindow`)
deleteUI mainWindow;
//windowPref -r mainWindow;
window -title "Main" -width 300 -height 400 mainWindow;
columnLayout -adj 1 mainCol;
textScrollList -width 285 -height 350 -ams true mainText;
popupMenu Menu;
menuItem -l "List Attributes" -c "listAttributes()";
button -l "Refresh" -c "refreshBtn()" mainBtn;
showWindow mainWindow;
global proc refreshBtn()
{
textScrollList -e -ra mainText;
string $selected[] = `ls -l -sl`;
for($i in $selected){
textScrollList -e -append $i mainText;
}
}
global proc listAttributes()
{
string $listAttr[] = `textScrollList -q -si mainText`;
int $size = size($listAttr);
for($i = 0; $i <= size($listAttr); $i++){
string $listAttributes[] = `listAttr -k $listAttr`;
int $sizeAttr = size($listAttributes);
if (`window -exists attrWindow`)
deleteUI attrWindow;
window -title "Attributes" -width 200 -height 300 attrWindow;
columnLayout -adj 1 attrCol;
textScrollList -width 200 -height 250 -ams true attrText;
popupMenu attrMenu;
menuItem -l "Key" -c "keyThem()";
menuItem -l "Delete Key" -c "deleteThem()";
for($i = 0; $i <= $sizeAttr; $i++){
textScrollList -e -append $listAttributes[$i] attrText;
}
string $selectedAttrs[] = `textScrollList -q -si attrText`;
for($j = 0; $j <= size($selectedAttrs); $j++){
setKeyframe -at $selectedAttrs[$j];
}
showWindow attrWindow;
}
}
global proc keyThem()
{
string $selectedAttrs[] = `textScrollList -q -si attrText`;
for($j = 0; $j <= size($selectedAttrs); $j++){
setKeyframe -at $selectedAttrs[$j];
}
}
//RIGHT HERE :(
global proc deleteThem(){
string $listAttr[] = `textScrollList -q -si mainText`;
string $selectedAttrs[] = `textScrollList -q -si attrText`;
int $size = size($listAttr);
int $sizeAttr = size($selectedAttrs);
for($j = 0; $j <= $sizeAttr; $j++){
for($k = 0; $k <= size($selectedAttrs); $k++){
CBdeleteConnection ($listAttr[$j] + "." + $selectedAttrs[$k]);
}
}
}
Well i created simple UI that pretty much selects objects in a scene and displays their attributes, i do that for practicing.
So the thing is i was able to select and set keyframes on multiple objects, and list all their attributes into another textScrollList, but when comes to deleting all keyframes i am only able to delete on one selected. This has to do with loops, whcih i can't get the sence.
Take a look all the way in the bottom, i am putting whole script.
Sorry for the mess, i believe there should be two loops to loop first for selected objects, let's say 3 times, and loop to select their attributes, then to use the deletion function.
if(`window -exists mainWindow`)
deleteUI mainWindow;
//windowPref -r mainWindow;
window -title "Main" -width 300 -height 400 mainWindow;
columnLayout -adj 1 mainCol;
textScrollList -width 285 -height 350 -ams true mainText;
popupMenu Menu;
menuItem -l "List Attributes" -c "listAttributes()";
button -l "Refresh" -c "refreshBtn()" mainBtn;
showWindow mainWindow;
global proc refreshBtn()
{
textScrollList -e -ra mainText;
string $selected[] = `ls -l -sl`;
for($i in $selected){
textScrollList -e -append $i mainText;
}
}
global proc listAttributes()
{
string $listAttr[] = `textScrollList -q -si mainText`;
int $size = size($listAttr);
for($i = 0; $i <= size($listAttr); $i++){
string $listAttributes[] = `listAttr -k $listAttr`;
int $sizeAttr = size($listAttributes);
if (`window -exists attrWindow`)
deleteUI attrWindow;
window -title "Attributes" -width 200 -height 300 attrWindow;
columnLayout -adj 1 attrCol;
textScrollList -width 200 -height 250 -ams true attrText;
popupMenu attrMenu;
menuItem -l "Key" -c "keyThem()";
menuItem -l "Delete Key" -c "deleteThem()";
for($i = 0; $i <= $sizeAttr; $i++){
textScrollList -e -append $listAttributes[$i] attrText;
}
string $selectedAttrs[] = `textScrollList -q -si attrText`;
for($j = 0; $j <= size($selectedAttrs); $j++){
setKeyframe -at $selectedAttrs[$j];
}
showWindow attrWindow;
}
}
global proc keyThem()
{
string $selectedAttrs[] = `textScrollList -q -si attrText`;
for($j = 0; $j <= size($selectedAttrs); $j++){
setKeyframe -at $selectedAttrs[$j];
}
}
//RIGHT HERE :(
global proc deleteThem(){
string $listAttr[] = `textScrollList -q -si mainText`;
string $selectedAttrs[] = `textScrollList -q -si attrText`;
int $size = size($listAttr);
int $sizeAttr = size($selectedAttrs);
for($j = 0; $j <= $sizeAttr; $j++){
for($k = 0; $k <= size($selectedAttrs); $k++){
CBdeleteConnection ($listAttr[$j] + "." + $selectedAttrs[$k]);
}
}
}
