Hi you all I am stuck in a small issue with a mell script.
I made just for exercise a small script that load objects selected from the viewport in a textScrollList and rename it.
I would be able to remove some items aready loaded in the list selecting them from the textScrollList (i was able to do that) and use a procedure to remove them from the textScrollList.
some of you nice people has some good advice for a newbie? I hope you can hel me. Here follow the code I am using so far and that works until this critical point.
Cheers
Francesco
// Procedure to create the UI
global proc makeUI ()
{
if (window -exists myRenameUI)
deleteUI myRenameUI;
windowPref -r myRenameUI;
window -title "Rename Those Items" -w 300 -h 550 -sizeable off myRenameUI;
columnLayout -adj off renameCol;
// here I allow the multi selection on the textScrollList
textScrollList -height 300 -width 300 -allowMultiSelection on toRenameTSL;
button -label "Get Items" -width 300 -c getItems getButton;
button -label "Clear All" -width 300 -c clearAllProc clearAll;
button -label "remove Selected" -width 300 -c clearSelectedProc clearSelected;
textField -width 500 -it "insert new name" newNameTF;
button -label "Rename" -width 300 -c renameThis renameButton;
showWindow myRenameUI;
}
// Procedure to load the objects selected in the scene in the textScrollList
global proc getItems ()
{
textScrollList -e -removeAll toRenameTSL;
string $objInScene[] = ls -sl;
print $objInScene;
for ($eachObj in $objInScene)
{
textScrollList -e -append $eachObj toRenameTSL;
}
}
// Procedure to perform the renaming
global proc renameThis()
{
string $objToRename[] = textScrollList -q -allItems toRenameTSL;
string $newName=textField -q -text newNameTF;
for ($eachObjToRename in $objToRename)
{
rename $eachObjToRename ($newName + "_#");
}
}
// Procedure to clear the content of the textScrollList
//(useless, i know, just practicing with commands and flags)
global proc clearAllProc()
{
textScrollList -e -removeAll toRenameTSL;
}
// !!! Here there is !!! //
// that was my idea: create a procedure that is suppose to:
// - read the selection
// - cast the strings in an array
// - perform a FOR...IN loop based on the array content to remove the items from the textScrollList
//
//Please notice: every other more efficent solution is more than welcome
global proc clearSelectedProc()
{
//this print just the number of item selected from the scroll list
int $testVar=textScrollList -q -numberOfSelectedItems toRenameTSL;
print $testVar;
}