Hi guys
I wrote a simple mel script for setting project. (example of script attatched below)
In our pipeline we are using a project for every shot in the show.
Script works fine until the shot list gets too long so I want to refine it so that there are subfolders.
How it works now is there is a text field, when you click on it it creates and displays a list of every folder in the shot directory.
when you highlight and release an item it will set shot to that project.
the shots are named like
tbw0010
tbw0020
enb0100
enb0120
and so on
so what i’d like to do is have it make a list based on first 3 letters and then a sublist for each #suffix of the shot.
tbw
-0010
-0020
enb
-0100
-0120
and so on. (dash is just for visual purposes)
Can anyone help me with the mel syntax for that? I am by no means and expert scripter. I wrote the original one a year ago when i was doing some mel training. So I am rusty on top of that.
I’m open to changes in the way it works and gui as well if someone suggests a better method
of doing it. I’ve attatched a sample of the script.
The main bit of code is
string $listOfShots[] = getFileList -folder “D:/project/shots/"
;
which was easy to figure out, what is a bit beyond me is stripping the prefix and nesting the shot# into sub popouts.
Thanks guys!
current script...
global proc setShot()
{
// Check for window and delete if needed
if (window -exists nfSetShotWin
) {
deleteUI -window nfSetShotWin;
}
// Create UI
window -menuBar true -title "Set Shot" -sizeable false -wh 300 80 nfSetShotWin;
rowColumnLayout -nc 2 -cw 1 70 -cw 2 200;
string $listOfFolders[] = getFileList -folder "D:/project/shots/"
;
string $folders[] = sort $listOfFolders
;
text -bgc .5 .5 .5 "shot name" ;
string $shotList;
textField -tx "click to set shot" -w 120 shotName;
popupMenu -button 1;
for($i = 0; $i < size($folders)
; $i++)
{
string $shotList = $folders[$i];
// menuItem -label ($shotList) -command ("[textField -edit -text " + $shotList +"] shotName");
menuItem -label ($shotList) -command ("getShot("+ $i +")");
}
button -bgc .8 .3 .4 -c "deleteUI -window nfSetShotWin" -label "CLOSE" setButton;
showWindow nfSetShotWin;
}
/////////////////////////////////////////////
/////////////////////////////////////////////
global proc getShot(int $listNum)
{
string $listOfShots[] = getFileList -folder "D:/project/shots/"
;
string $shots[] = sort $listOfShots
;
textField -edit -text $shots[$listNum] shotName;
setMyShot();
}
//////////////////////////////////////////////
//////////////////////////////////////////////
global proc setMyShot()
{
string $shotToSet = textField -q -tx shotName
;
setProject ("D:/project/shots/" + $shotToSet + "/3D");
print ("shot set to D:/project/shots/" + $shotToSet + "/3D\n");
headsUpMessage ("shot set to D:/project/shots/" + $shotToSet + "/3D") -t 2;
}
//////////////////////////////////////////////