/* camManager 1.6 by Ced and Sapo 15 november 2001 (v3) << grain.s@free.fr >> ------------------------------------------------- Visit the grain.S project at http://grain.s.free.fr ------------------------------------------------- With this tool you can easily manage your cameras... I'm bore to go Panels>Perspective to choose a camera. You can choose between ALL the available cameras in your scene. In order to run this tool you need to have the script cameraMain(highend3d.com). With the camManager script you can easily switch between cameras during animation, but don't rename the cameras it cause disfonction. Now you can switch faster, add some comments... to the current camera. ------------------- HOW USE THIS TOOL : ------------------- -camera? part : - here you can choose all cameras between 1 and 20 (or 21 and 40, 41 and 60, etc...) - M button : choose cameraMain (you can use right mouse button for more options) Menu (right mouse button) : -select (replace and add) : select cameraMain -Snapshot : Call snapshot for cameraMainif RenderWindow is open - -20, +20 and text : to choose more than 20 camera. Clic on +20 ("+20" is noticed). Now you can choose between 21 and 40. -comment part : see the comment for the last selected camera Menu (Left mouse button) : -Dp : duplicate the current camera -Rn : rename the current camera -Pt : permute 2 cameras names -Lock/Unlock : (un)lock transformations for the current camera -Bookmark : Call the bookmark window -Snapshot : Call snapshot for the current camera if RenderWindow is open -Operation part : -1st line : Here you can select all parts of the camera. Buttons changes if the current camera is 1, 2 or 3 nodes. CAM : select the camera itself Aim : select the view node camera (2/3 nodes cameras) Grp : select the Group node camera (2/3 nodes cameras) Up : select the Up node camera (3 nodes cameras) + : add the current camera to the selection -2nd line -attr : change attribute for the last selected camera to : overscan 1.2, resolution gate, Journal. (if you want change theses settings, edit the 2 fist MEL lines after comments.) -Com : button : add comment for the current camera -look : look at the selected object -3rd line -rec : record the current camera number like a keyframe for cameraMain.cameraNumber attribut -Get : get the current camera from cameraMain.cameraNumber attribut. -disp : switch between : display nothing/FieldChart/SafeAction -4rd line -<< : goto the the previous key on cameraMain.cameraMain Menu : you can move the previous key -camera- on cameraManager at the current time). ->> : goto the the next key on cameraMain.cameraMain. Menu : you can move the next key -camera- on cameraManager at the current time) -|<>| : set the timeLine to the min+max of the current camera (only with cameraMain) Menu : -print info about camera under the current time -Extend the time range to the previous camera -Extend the time range to the next camera -? : help window. ------------------- LIMITATIONS AND NOTES : ------------------- LIMITATIONS AND BUGS: - (IMPORTANT) You MUST have "persp" at the root of your scene. Otherway, camManager will not work.... If you want to parent an objet to a persp camera, use another persp (persp1, etc...) -You must restart the script when you load a new scene -the switch command doesn't support 2/3 nodes camera yet -The duplicate command doesn't support 2/3 nodes camera yet -You can only change camera on a cam/persp panel (not, Outliner, Hypershade, etc...). WORKAROUND : switch panel to persp with Marking Menu, and use cameraManager.... -Operations works only with camera selected/see using cameraManager tools (not when you selected/see with standard tools...) -There is no UI to change attributs setting of the camera. You must edit this file. -Be carefull, when you use a lot duplicate with 2/3 nodes camera, verify often if ALL the names of you cam objects are good (especially the camera# FUTURE FEATURES (but I think that I will not have the time!!!) : -add a list of all cameras in the scene (case where you have another name to cameras that "camera#") -support for multiple cameraMain (and change the camera main script) -Control clip plane of the current camera. -add a settings window -any other Request?? -May be clean the code. But I'm not a very good coder... sorry. If someone want try to write something better and faster.... HOW IT WORKS? : this script add some attributs to the persp cam. Do not remove theses attributs!!. If you remove one attribut, you must remove all other by hand Theses attributs records the last selected camera and the addition number. There is a attribut to the selected camera too. It's the comment. By this way, your comments/prefs are scene dependant. ------------------ HISTORY : ------------------ New in 1.0 : -comment features. -small window -You are not limit to 40 cameras -sel -add feature -resolution gate to the attr button -You can select the cameraMain camera from the cameraMain script -Support camera with 2 or 3 nodes New in 1.11 : -fix some big bugs in some specials occasions. -Annotations over buttons. New in 1.2 : -fix some bugs in some specials occasions. -keep old comments when you press "cancel" button of Com feature. -fix big bug with cameraMain script. You can now use my script with cameraMain script. New in 1.5 : -add feature : you can look at an object with the current camera -add a tool to easy rename the camera# -add a tool to easy switch the camera# -add a tool to see FieldChart/Safe action -add a tool to select the current camera from the cameraMain # -add a tool to duplicate the current camera -add buttons to go to the next/prev camera# in the timeline (use only with cameraMain) -add buttons to set the time range to the current camera# -add help window -add options (right mouse button) to the "M" , >>, << and |<>| button, to manage the time range and the next/previous camera cut. -attr button now put "Journal" to 1 (camera is undoable) -all buttons are now refresh when you push "+20" or "-20" -you can change the attributs settings (but you must edit the MEL file.... ) -you can now select all parts of 2/3 nodes camera -minors changes... -bugs fix... New in 1.6 (not public release yet...): -If the camera doesn't exist, the button is disable (automaticmy updated when you call Dup feature) -cleaner UI : less buttons, and other features move to clic on comment line.... -new feature : call bookmark window -new feature : create 1/2/3 node camera -new feature : lock/unlock feature (to add) -new feature : you can now easly call snapshot for current camera or cameraMain -support of more than 100 cameras.. (but the layout will be bigger...) -feedbacks in the script editor are now preceded by "//" -bugs fix... ---------------------- Thanks to jlof, Alin Sfetcu and Attila Sziklai. Please report bugs. Works only with Maya4.0. Tested on NT --------------------- This script is MAILWARE. So mail me if you use it!! <<<<< grain.s@free.fr >>>>>> */ //SETTINGS----------------------------------- //Change here your the attr setting.... //you must type in the script editor before running the script if you change these settings... // 1-filmFit setting : fill=0 ; horizontal=1 ; vertical=2 ; overscan=3. global int $customFilmFit = 3 ; // 2-overscan setting global float $customOverscan = 1.3 ; // 3-your fps setting global int $cm_fps = 25; //------------------------------------------ //main proc global proc camManager (){ global string $comm; if ((`window -ex camMan`) == true) deleteUI camMan; window -t "camera Manager 1.5" -h 220 -width 160 camMan ; //detect if the attribut CM_camN exist. if ( (`attributeExists "CM_camN" persp`)== 0 ) { //This attribut doesnt exists. Create it addAttr -ln CM_camN -dt "string" |persp; setAttr -e -keyable true |persp.CM_camN; addAttr -ln CM_add -at long |persp; setAttr -e -keyable true |persp.CM_add; print ("//camManager initialyse : add attributs to persp object. Visit the Grain.S project at http://grain.s.free.fr" + ";\n"); } //Detect the current camera with the persp.CM_camN attribut string $camCurrent; $camCurrent = (`getAttr persp.CM_camN`); string $camCurrentComplete = ( "camera" + $camCurrent); //add the attribut CM_comm, to put the futur comment to the current camera (if this camera exist). if (`objExists $camCurrentComplete`) { if ( (`attributeExists "CM_comm" $camCurrentComplete`)== 0 ) { addAttr -ln CM_comm -dt "string" $camCurrentComplete ; string $camCurrentCompleteAttribute = ( $camCurrentComplete + ".CM_comm"); setAttr -e -keyable true $camCurrentCompleteAttribute; print ("//Add comment attribut to the current camera" + ";\n"); } } //----------------------------------------------------- //generate the array who store the name and the state of the buttons int $curAddb; $curAddb = (`getAttr persp.CM_add`); string $camNumDisp[]; //name of the button int $numTemp; //store a temp number int $si; //increment string $camName; int $camExist[]; for($si = 1; $si<21;$si++) { $numTemp = $curAddb + $si; $camNumDisp[$si] = $numTemp; $camName = ("camera" + $numTemp); //print $camName; //debug //state of the button... if (`objExists $camName`) $camExist[$si] = 1; else $camExist[$si] = 0; //print ($camExist[$si] + ";\n"); //debug } //end of the generate! //------------------------------------------------------- //detect if there is more than 100 cameras. If yes, upgrade the button size. int $cmSize; if ($curAddb <100) $cmSize = 20; else $cmSize = 25; //Create interface columnLayout -adj 1; //tab 1 frameLayout -ann "view through a camera" -l "camera?" -la "center" -bs "etchedIn" -cll 1 -cl 0; columnLayout -adj 1; rowLayout -nc 5 -cw5 $cmSize $cmSize $cmSize $cmSize $cmSize -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0 -cat 5 "both" 0; button -en $camExist[1] -ann "view through the camera#" -w 10 -l $camNumDisp[1] -c "camSel ( 1, 0 );"; button -en $camExist[2] -ann "view through the camera#" -w 10 -l $camNumDisp[2] -c "camSel ( 2, 0 );"; button -en $camExist[3] -ann "view through the camera#" -w 10 -l $camNumDisp[3] -c "camSel ( 3, 0 );"; button -en $camExist[4] -ann "view through the camera#" -w 10 -l $camNumDisp[4] -c "camSel ( 4, 0 );"; button -en $camExist[5] -ann "view through the camera#" -w 10 -l $camNumDisp[5] -c "camSel ( 5, 0 );"; setParent..; rowLayout -nc 5 -cw5 $cmSize $cmSize $cmSize $cmSize $cmSize -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0 -cat 5 "both" 0; button -en $camExist[6] -ann "view through the camera#" -w 10 -l $camNumDisp[6] -c "camSel ( 6, 0 );"; button -en $camExist[7] -ann "view through the camera#" -w 10 -l $camNumDisp[7] -c "camSel ( 7, 0 );"; button -en $camExist[8] -ann "view through the camera#" -w 10 -l $camNumDisp[8] -c "camSel ( 8, 0 );"; button -en $camExist[9] -ann "view through the camera#" -w 10 -l $camNumDisp[9] -c "camSel ( 9, 0 );"; button -en $camExist[10] -ann "view through the camera#" -w 10 -l $camNumDisp[10] -c "camSel ( 10, 0 );"; setParent..; rowLayout -nc 5 -cw5 $cmSize $cmSize $cmSize $cmSize $cmSize -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0 -cat 5 "both" 0; button -en $camExist[11] -ann "view through the camera#" -w 10 -l $camNumDisp[11] -c "camSel ( 11, 0 );"; button -en $camExist[12] -ann "view through the camera#" -w 10 -l $camNumDisp[12] -c "camSel ( 12, 0 );"; button -en $camExist[13] -ann "view through the camera#" -w 10 -l $camNumDisp[13] -c "camSel ( 13, 0 );"; button -en $camExist[14] -ann "view through the camera#" -w 10 -l $camNumDisp[14] -c "camSel ( 14, 0 );"; button -en $camExist[15] -ann "view through the camera#" -w 10 -l $camNumDisp[15] -c "camSel ( 15, 0 );"; setParent..; rowLayout -nc 5 -cw5 $cmSize $cmSize $cmSize $cmSize $cmSize -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0 -cat 5 "both" 0; button -en $camExist[16] -ann "view through the camera#" -w 10 -l $camNumDisp[16] -c "camSel ( 16, 0 );"; button -en $camExist[17] -ann "view through the camera#" -w 10 -l $camNumDisp[17] -c "camSel ( 17, 0 );"; button -en $camExist[18] -ann "view through the camera#" -w 10 -l $camNumDisp[18] -c "camSel ( 18, 0 );"; button -en $camExist[19] -ann "view through the camera#" -w 10 -l $camNumDisp[19] -c "camSel ( 19, 0 );"; button -en $camExist[20] -ann "view through the camera#" -w 10 -l $camNumDisp[20] -c "camSel ( 20, 0 );"; setParent..; //get the current add feature string $curAdd; $curAdd = (`getAttr persp.CM_add`); string $curAddComplete = ( "+" + $curAdd); rowLayout -nc 4 -cw4 20 30 25 25 -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0; button -ann "view through cameraMain" -w 10 -l "M" -c "camSel ( 0, 0 );"; popupMenu ; menuItem -l "select cameraMain (replace)" -to 1 -c "select cameraMain;" ; menuItem -l "select cameraMain (add)" -to 1 -c "select -add cameraMain;" ; menuItem -l "snapshot cameraMain" -to 1 -c "callsnaps (0);"; text -ann "current increment camera number" -label $curAddComplete -align "center"; button -ann "-20 to the increment camera number" -w 15 -l "-20" -c "selPlus 1;"; button -ann "+20 to the increment camera number" -w 15 -l "+20" -c "selPlus 0;"; setParent ..; separator; //comment tab string $camCurrentCompleteAttribute = ( $camCurrentComplete + ".CM_comm"); if (`objExists $camCurrentComplete`) { string $comm = (`getAttr $camCurrentCompleteAttribute`); string $commComplete = ($camCurrent + " = " + $comm); text -ann "camera# = comment (clic for other commands)" -label $commComplete -align "center"; popupMenu -button 1; menuItem -l "Duplicate" -to 1 -c "dup;" ; menuItem -l "Rename" -to 1 -c "renCam;" ; menuItem -l "permute 2 cameras" -to 1 -c "permCam;" ; menuItem -l "lock/Unlock" -to 1 -c "lockUnlock;" ; menuItem -l "Bookmark" -to 1 -c "callBookmark;" ; menuItem -l "snapshot" -to 1 -c "callsnaps (1);"; //print ("cLa" + ";\n"); } setParent..; setParent..; //tab3 frameLayout -ann "fast tasks on cameras" -l "Operations" -la "center" -bs "etchedIn" -cll 1 -cl 0; columnLayout -adj 1; string $cam3nodes = ( $camCurrentComplete + "_up" ) ; string $cam2nodes = ( $camCurrentComplete + "_view" ) ; //buttons are selection dependant (1/2/3 camera nodes....) if ( (`objExists $cam3nodes`) && (`objExists $cam2nodes`) ) { rowLayout -nc 5 -cw5 21 21 21 21 15 -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0 -cat 5 "both" 0; button -ann "select the current viewed camera" -w 21 -l "CA" -c "selCurCam 0;"; button -ann "select the current viewed camera group" -w 21 -l "grp" -c "selCurCam 1;"; button -ann "select the current viewed camera aim" -w 21 -l "aim" -c "selCurCam 2;"; button -ann "select the current viewed camera up" -w 21 -l "up" -c "selCurCam 3;"; button -ann "select and add the current viewed camera" -w 15 -l "+" -c "selCurCam -1;"; setParent..; } if ( (`objExists $cam3nodes` == 0) && (`objExists $cam2nodes`) ) { rowLayout -nc 4 -cw4 28 28 29 15 -cat 1 "both" 0 -cat 2 "both" 0; button -ann "select the current viewed camera" -w 28 -l "CAM" -c "selCurCam 0;"; button -ann "select the current viewed camera group" -w 28 -l "grp" -c "selCurCam 1;"; button -ann "select the current viewed camera aim" -w 29 -l "aim" -c "selCurCam 2;"; button -ann "select and add the current viewed camera" -w 15 -l "+" -c "selCurCam -1;"; setParent..; } if ( (`objExists $cam3nodes` == 0) && (`objExists $cam2nodes` == 0) ) { rowLayout -nc 2 -cw2 85 15 -cat 1 "both" 0; button -ann "select the current viewed camera" -w 33 -l "CAM" -c "selCurCam 0;"; button -ann "select and add the current viewed camera" -w 15 -l "+" -c "selCurCam -1;"; setParent..; } //operations rowLayout -nc 3 -cw3 33 33 34 -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0; button -ann "change attributs to Overscan 1.2, resolution gate, Journal" -w 25 -l "Attr." -c "changeAttr"; button -ann "change the comment for the last viewed camera" -w 25 -l "Com." -c "SCommentaire;"; button -ann "lookAt" -w 25 -l "look" -c "lookatSelection;"; setParent..; rowLayout -nc 3 -cw3 33 33 34 -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0; button -ann "Key cameraMain.cameraNumber with the current camera at current time" -w 20 -l "Rec" -c "rec_cm"; button -ann "Get the current camera from cameraMain" -w 20 -al "left" -l "Get" -c "get;"; button -ann "switch SafeAction / FieldChart" -w 25 -l "Disp." -c "switchFc;"; setParent..; //time line operations rowLayout -nc 4 -cw4 30 30 25 15 -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cat 4 "both" 0; button -ann "Jump to the previous camera" -w 20 -l "<<" -c "gotoCm 0;"; popupMenu ; menuItem -l "move previous key (camera) here" -to 1 -c "cm_moveKey (0);" ; button -ann "Jump to the next camera" -w 20 -l ">>" -c "gotoCm 1;"; popupMenu ; menuItem -l "move next key (camera) here" -to 1 -c "cm_moveKey (1);" ; button -ann "Set timeLine range to the actual camera range" -w 20 -l "|<>|" -c "setCm (0);"; popupMenu ; menuItem -l "just print info about current camera..." -to 1 -c "setCm (-1);" ; menuItem -l "Extend timeLine to the previous key (camera)" -to 1 -c "extCm (0);" ; menuItem -l "Extend timeLine to the next key (camera)" -to 1 -c "extCm (1);" ; button -ann "help..." -w 20 -l "?" -c "cm_Help;"; setParent..; setParent..; showWindow; } //panel the camera // arg : $camN = number from the camManager UI only // $realNbr = 0 if the cam number must be read from the persp attribut (proc doesn't called from UI) // 1 if the cam number is read from the UI. global proc camSel(int $camN, int $realNbr) { int $realCamN; int $curAdd; if ( $realNbr == 0 ) { $curAdd = (`getAttr persp.CM_add`); //calculate the real camera number $realCamN = $camN + $curAdd; } else { $realCamN = $camN; } string $curCam; //det if the current camera is cameraMain if ($camN == 0) $curCam = "cameraMain" ; else $curCam = ("camera" + $realCamN); //test if the camera exist and if it's not the cameraMain if ( (`objExists $curCam`) && ($camN != 0) ) { print ("//Current camera : camera" + $realCamN + ";\n"); //upgrade the CM_camN attribut to transfert the current cam number. setAttr -type "string" persp.CM_camN $realCamN; //recall the interface to upgrade the comment camManager(); //action! lookThru perspView $curCam; } //if it's the cameraMain if ( (`objExists $curCam`) && ($camN == 0) ) { print ("//Current camera : cameraMain" + ";\n"); //upgrade the CM_camN attribut to transfert the current cam number. setAttr -type "string" persp.CM_camN "Main"; //recall the interface to upgrade the comment camManager(); //action! lookThru perspView cameraMain; } //if cam doesn't exist if (`objExists $curCam` == 0) warning ( $curCam + " doesn't exists. " + ";\n"); } //add to current selection // arg : 1 for -20 to increment # // 0 for +20 to increment # global proc selPlus (int $AddMinus) { int $curAdd; $curAdd = (`getAttr persp.CM_add`); if ($AddMinus == 0) $curAdd = $curAdd + 20 ; if ( ($AddMinus == 1) && ($curAdd >0) ) $curAdd = $curAdd - 20 ; setAttr "persp.CM_add" $curAdd; camManager(); } //change the current comment global proc SCommentaire() { //get current camera string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber + ".CM_comm"); string $comm = (`getAttr $currentCamera`); //open dialog box string $text; string $result = `promptDialog -text $comm -title "comment?" -message "enter the comment:" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; //action! (or not) if ($result == "OK") { $text = `promptDialog -q`; print ("//You changed the comment for camera" + $currentCamNumber + ";\n"); } if ($result == "Cancel") { $text = `getAttr $currentCamera`; print ("//You cancelled the comment for camera" + $currentCamNumber + ";\n"); } setAttr -type "string" $currentCamera $text; //recall interface to upgrade the comment camManager(); } // Select the current camera //arg : how many node for the cam? global proc selCurCam(int $selChoice) { //get the cam name string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); string $camName = ("camera" + $currentCamNumber); string $camGrp = ( $camName + "_group" ) ; string $cam3nodes = ( $camName + "_up" ) ; string $cam2nodes = ( $camName + "_view" ) ; //action in case 1 or 2 (-r or -add) if ($selChoice==0) { select -r $camName; print ("//selected : " + $camName + ";\n"); } if ($selChoice==1) { select -r $camGrp; print ("//selected : " + $camName + " GROUP" + ";\n"); } if ($selChoice==2) { select -r $cam2nodes; print ("//selected : " + $camName + " AIM" + ";\n"); } if ($selChoice==3) { select -r $cam3nodes; print ("//selected : " + $camName + " UP" + ";\n"); } if ($selChoice==-1) { select -add $camName; print ( "//" + $camName + " added to selection" + ";\n"); } } //Change the current camera attribut global proc changeAttr() { global int $customFilmFit ; global float $customOverscan ; //what is selected? string $temp[] = `ls -sl`; string $thing; //this will change attributs for ALL selected objects (cam or not cam, but error message if not..) for ($thing in $temp) { //action! camera -e -journalCommand 1 -displayFilmGate off -displayResolution on -overscan $customOverscan $thing; //because it can't change to overscan (I don't know why...) string $ff = ($thing + ".filmFit"); setAttr $ff $customFilmFit; }; } //Rename the current camera global proc renCam() { //get current camera string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber ); //ask the new number int $nvNum; string $result = `promptDialog -title "Rename Camera" -message "Enter the new number of the actual camera" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; //if you are OK.... if ($result == "OK") { $nvNum = `promptDialog -q`; string $newCamera = ("camera" + $nvNum) ; string $cam3nodes = ( $currentCamera + "_up" ) ; string $cam2nodes = ( $currentCamera + "_view" ) ; //if the new n is already used if (`objExists $newCamera`) { //open dialog box int $choix; string $result = `promptDialog -title "probleme!!" -message "This cam exist. Permute? 0/1" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; //action! (or not) if ($result == "OK") { $choix = `promptDialog -q`; if ($choix == 1) { rename $newCamera "CameraTemp"; rename $currentCamera $newCamera; rename "CameraTemp" $currentCamera; print ( "//" + $newCamera + " and " + $currentCamera + " permuted." + ";\n"); } } } else { if ( (`objExists $cam3nodes`) && (`objExists $cam2nodes`) ) { $newCamera = ("camera" + $nvNum ); rename $currentCamera $newCamera; rename ($currentCamera + "_group") ($newCamera + "_group"); rename ($currentCamera + "_view") ($newCamera + "_view"); rename ($currentCamera + "_up") ($newCamera + "_up"); } if ( (`objExists $cam3nodes` == 0) && (`objExists $cam2nodes`) ) { $newCamera = ("camera" + $nvNum ); rename $currentCamera $newCamera; rename ($currentCamera + "_group") ($newCamera + "_group"); rename ($currentCamera + "_view") ($newCamera + "_view"); } if ( (`objExists $cam3nodes` == 0) && (`objExists $cam2nodes` == 0) ) { $newCamera = ("camera" + $nvNum ); rename $currentCamera $newCamera; } print ( "//" + $currentCamera + " rename to " + $newCamera + ";\n"); } camManager; } } //Permute 2 cameras names global proc permCam() { string $cam_b_name ; string $cam_a_name ; //open dialog box int $cam_a; string $result = `promptDialog -title "Permute cameras (step 1/2)" -message "Enter the number of the first camera to permute" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; //action! (or not) if ($result == "OK") { $cam_a = `promptDialog -q`; $cam_a_name = ("camera" + $cam_a ); } //open dialog box int $cam_b; string $result = `promptDialog -title "Permute cameras (step 2/2)" -message "Enter the number of the second camera to permute" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; //action! (or not) if ($result == "OK") { $cam_b = `promptDialog -q`; $cam_b_name = ("camera" + $cam_b ); } //action! (or not) string $cama2nodes = ( $cam_a_name + "_view" ) ; string $camb2nodes = ( $cam_b_name + "_view" ) ; if ( (`objExists $cama2nodes`) || (`objExists $camb2nodes`) ) { messageWin ( "sorry, you can't permute 2/3 nodes camera yet..."); } else { if ( (`objExists $cam_a_name`) && (`objExists $cam_a_name`) ) { rename $cam_b_name "CameraTemp"; rename $cam_a_name $cam_b_name; rename "CameraTemp" $cam_a_name; print ( "//" + $cam_a_name + " and " + $cam_b_name + " permuted"+ ";\n"); } } } //Record the current camera# in cameraMain.cameraNumber attribut global proc rec_cm() { //get current camera int $currentCamera; int $currentCamNumber = (`getAttr persp.CM_camN`); if (`objExists "cameraMain"`) { setKeyframe -attribute "cameraNumber" -v $currentCamNumber -itt "step" -ott "step" cameraMain; print ("//setKeyframe for camera" + $currentCamNumber + ";\n"); } else messageWin ("sorry,this feature only work with cameraMain (created by the cameraMain MEL script)"); } //switch display : none/FieldChart/safeaction global proc switchFc() { //get current camera string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber ); string $ff = ($currentCamera + ".displayFieldChart"); string $sa = ($currentCamera + ".displaySafeAction"); int $FFcurrentState = (`getAttr $ff`); int $SAcurrentState = (`getAttr $sa`); //action! (or not) if (($FFcurrentState == 0) && ($SAcurrentState == 0) ) { setAttr $ff 0; setAttr $sa 1; } if ( ($FFcurrentState == 0) && ($SAcurrentState == 1) ) { setAttr $ff 1; setAttr $sa 0; } if (($FFcurrentState == 1) && ($SAcurrentState == 0) ) { setAttr $ff 0; setAttr $sa 0; } } //Look at the selected object (thanks to Attila Sziklai) global proc lookatSelection () { string $currentPanel = `getPanel -withFocus`; string $panelType = `getPanel -to $currentPanel`; if ($panelType == "modelPanel") { string $camera = `modelEditor -q -camera $currentPanel`; viewLookAt $camera; } } //get the current cameraMain number and see this camera global proc get () { int $curCmN; if (`objExists "cameraMain"`) { $curCmN = (`getAttr cameraMain.cameraNumber`); camSel ( $curCmN, 1 ); print ("//You see now throught camera" + $curCmN + ";\n"); } else messageWin ("sorry,this feature only work with cameraMain (created by the cameraMain MEL script)"); } //duplicate the current camera global proc dup () { string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber ); string $newCamera; int $nvNum; //open dialog box string $result = `promptDialog -title "Duplicate current Camera#." -message "Enter the number of the new camera" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"` ; //action! (or not) if ($result == "OK") { $nvNum = `promptDialog -q`; $newCamera = ("camera" + $nvNum ); if (`objExists $newCamera`) { warning ( "sorry, " + $newCamera + " exist. Choose another camera " + ";\n"); } else { duplicate -rr -name $newCamera $currentCamera; print ( "//" + $currentCamera + " was duplicate in " + $newCamera + ";\n"); //recall interface to upgrade the comment camManager(); } } } //error window proc... global proc messageWin(string $phrase) { confirmDialog -t "cameraManager error" -m $phrase -b "Ok, ok..." -db "ok..."; } //goto the the next/prev key on cameraMain global proc gotoCm (int $prevNext) { //init float $currentTime = `currentTime -q`; float $currentTimeChanged; float $keyTime; float $camValue; float $durre; float $durreSec; float $nextkeyTime; global int $cm_fps; string $camCurrentCompleteAttribute; string $comm; if (`objExists "cameraMain"`) { //want you go backward or forward? if ($prevNext == 0) $keyTime = `findKeyframe -time $currentTime -which previous cameraMain`; if ($prevNext == 1) $keyTime = `findKeyframe -time $currentTime -which next cameraMain`; //get the current cam currentTime $keyTime; $camValue = (`getAttr cameraMain.cameraNumber`); $camCurrentCompleteAttribute = ( "camera" + $camValue + ".CM_comm"); $comm = (`getAttr $camCurrentCompleteAttribute`); //check what's the next cam $currentTimeChanged = `currentTime -q`; $nextkeyTime = `findKeyframe -time $currentTimeChanged -which next cameraMain`; $durre = $nextkeyTime - $keyTime; $durreSec = $durre/$cm_fps; //check if this is the last camera or not, and... action! if ($nextkeyTime == $keyTime) print ("//camera" + $camValue + " @time " + $keyTime + " (This is the last camera...)" + ";\n"); else print ("//camera" + $camValue + " @time " + $keyTime + " || shot lenght : " + $durre + "f - " + $durreSec + "s || Comment : " + $comm + ";\n"); } //oups... else messageWin ("sorry,this feature only work with cameraMain (created by the cameraMain MEL script)"); } global proc cm_moveKey (int $prevNext) { //init float $currentTime = `currentTime -q`; float $currentTimeChanged; float $keyTime; float $dif; float $durre; float $durreSec; float $nextkeyTime; global int $cm_fps; if (`objExists "cameraMain"`) { //want you go backward or forward? if ($prevNext == 0) $keyTime = `findKeyframe -time $currentTime -which previous cameraMain`; if ($prevNext == 1) $keyTime = `findKeyframe -time $currentTime -which next cameraMain`; $dif = $currentTime - $keyTime; keyframe -e -iub true -r -o over -tc $dif -t $keyTime cameraMain_cameraNumber ; } //oups... else messageWin ("sorry,this feature only work with cameraMain (created by the cameraMain MEL script)"); } //set the timeLine to the min+max of the current camera (only with cameraMain) global proc setCm (int $choice) { //init float $currentTime = (`currentTime -q` + 1); float $keyTimePrev; float $keyTimeNext; float $camValue; float $dure; float $dureS; global int $cm_fps; string $camCurrentCompleteAttribute; string $comm; //action... (or not) if (`objExists "cameraMain"`) { $keyTimePrev = `findKeyframe -time $currentTime -which previous cameraMain`; $keyTimeNext = `findKeyframe -time $currentTime -which next cameraMain`; if ($choice == 0) { playbackOptions -edit -minTime $keyTimePrev; playbackOptions -edit -maxTime ($keyTimeNext - 1); } $dure = ( ($keyTimeNext - 1) - $keyTimePrev ); $dureS = $dure / $cm_fps; $camValue = (`getAttr cameraMain.cameraNumber`); $camCurrentCompleteAttribute = ( "camera" + $camValue + ".CM_comm"); $comm = (`getAttr $camCurrentCompleteAttribute`); print ("//camera" + $camValue + " @time " + $keyTimePrev + " - " + ($keyTimeNext - 1) + " || shot lenght : " + $dure + "f - " + $dureS + "s || comment : " + $comm + ";\n"); } else messageWin ("sorry,this feature only work with cameraMain (created by the cameraMain MEL script)"); } //extend time line. global proc extCm (int $prevNext) { //init float $currentMin = `playbackOptions -q -minTime` ; float $currentMax = (`playbackOptions -q -maxTime`) + 1 ; float $keyTimePrev ; float $keyTimeNext ; float $minCamValue; float $maxCamValue; float $dure; float $dureS; global int $cm_fps; //action... (or not) if (`objExists "cameraMain"`) { //get actual timeLine range $keyTimePrev = `findKeyframe -time $currentMin -which previous cameraMain`; $keyTimeNext = `findKeyframe -time $currentMax -which next cameraMain`; //extend min time range if ($prevNext == 0) { playbackOptions -edit -minTime $keyTimePrev ; $camValue = (`getAttr -time $keyTimePrev cameraMain.cameraNumber`); $currentMin = `playbackOptions -q -minTime` ; $currentMax = `playbackOptions -q -maxTime` ; $dure = $currentMax- $currentMin; $dureS = $dure / $cm_fps; print ("//camera" + $camValue + " @time " + $keyTimePrev + " added to the time range. (Total range : " + $dure + "f " + $dureS + "s )" + ";\n"); } //extend max time range if ($prevNext == 1) { playbackOptions -edit -maxTime ($keyTimeNext - 1) ; $camValue = (`getAttr -time $keyTimeNext cameraMain.cameraNumber`); $currentMin = `playbackOptions -q -minTime` ; $currentMax = `playbackOptions -q -maxTime` ; $dure = $currentMax- $currentMin; $dureS = $dure / $cm_fps; print ("//camera" + $camValue + " @time " + $keyTimeNext + " added to the time range (Total range : " + $dure + "f " + $dureS + "s )" + ";\n"); } } else messageWin ("sorry, this feature only works with cameraMain (created by the cameraMain MEL script)"); } global proc callBookmark() { string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber ); //?? buildCameraBookmarkMenu MayaWindow|mayaMainWindowForm|formLayout3|viewPanes|modelPanel1|View|menuItem292 modelPanel1; cameraBookmarkEditor $currentCamera; print ("//You have called Bookmark window for " + $currentCamera + ";\n"); } global proc callsnaps (int $choice) { string $currentCamera; if ($choice == 1) { string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber ); } else $currentCamera = "cameraMain"; renderWindowRenderCamera snapshot renderView $currentCamera; } global proc lockUnlock() { string $currentCamera; string $currentCamNumber = (`getAttr persp.CM_camN`); $currentCamera = ("camera" + $currentCamNumber ); int $currselectstate; $currselectstate = `getAttr -lock ($currentCamera+".tx")`; if ($currselectstate ==true) { setAttr ($currentCamera+".tx") -lock false ; setAttr ($currentCamera+".ty") -lock false ; setAttr ($currentCamera+".tz") -lock false ; setAttr ($currentCamera+".rx") -lock false ; setAttr ($currentCamera+".ry") -lock false ; setAttr ($currentCamera+".rz") -lock false ; print ("//You have unlocked transformations attributs for camera" + $currentCamera + ";\n"); } else { setAttr ($currentCamera+".tx") -lock true ; setAttr ($currentCamera+".ty") -lock true ; setAttr ($currentCamera+".tz") -lock true ; setAttr ($currentCamera+".rx") -lock true ; setAttr ($currentCamera+".ry") -lock true ; setAttr ($currentCamera+".rz") -lock true ; print ("//You have locked transformations attributs for camera" + $currentCamera + ";\n"); } } // help window.... global proc cm_Help() { window //Create a window -title "cameraManager Help" //Label on the title bar -iconName "Help" //Icon name when window is minimized -sizeable true //Let user resize the window -resizeToFitChildren true //Resize to fit the things inside of it cm2_helpWindow; //Name of the window columnLayout //Column Layout -adjustableColumn true //Make the columns adjustable -columnAlign "left" //Align left layoutOne; //Layout Name text -l ""; text -al "center" -l "cameraManager 1.6 by Ced+Sapo"; button -al "center" -ann "goto URL" -w 25 -l "visit the grain.s project : http://grain.s.free.fr" -c "gotoUrl;"; text -l ""; text -l "HOW TO USE THIS TOOL:"; text -l ""; text -l " -camera? part:"; text -l " - here you can choose all cameras between 1 and 20 (or 21 and 40, 41 and 60, etc...)"; text -l " - M button : choose cameraMain (you can use right mouse button for more options)"; text -l " - -20, +20 and text : to choose more than 20 cameras. Clic on +20 (+20 is noticed)."; text -l ""; text -l " -comment part: see the comment for the last selected camera"; text -l " Menu (Left mouse button) :"; text -l " -Dp : duplicate the current camera"; text -l " -Rn : rename the current camera"; text -l " -Pt : permute 2 cameras names"; text -l " -Lock/Unlock : (un)lock transformations for the current camera "; text -l " -Bookmark : Call the bookmark window"; text -l " -Snapshot : Call snapshot for the current camera if RenderWindow is open"; text -l ""; text -l " -Operation part:"; text -l " - CAM: select the camera itself"; text -l " - Aim: select the view node camera (2/3 nodes cameras)"; text -l " - Grp: select the Group node camera (2/3 nodes cameras)"; text -l " - Up: select the Up node camera (3 nodes cameras)"; text -l " - +: add the current camera to the selection"; text -l ""; text -l " - Attr: change attributes for the last selected camera to: overscan 1.3, resolution gate, journal."; text -l " (you can change theses settings if you edit the cameraManager.mel file"; text -l " - Com: add comments to the current camera"; text -l " - look: look at the selected object"; text -l ""; text -l " - rec: record the current camera number like a keyframe for cameraMain.cameraNumber attribut"; text -l " - Gt: get the current camera from cameraMain.cameraNumber attribut."; text -l " - Disp: switch between: display nothing/FieldChart/SafeAction"; text -l ""; text -l " - <<: goto the previous key on cameraMain.cameraMain. (options with RMB)"; text -l " - >>: goto the next key on cameraMain.cameraMain. (options with RMB)"; text -l " - |<>|: set the timeLine to the min+max of the current camera (only with cameraMain) (options under RMB)"; text -l " - ?: help window."; text -l ""; text -l ""; text -l "TIPS : - display the command line, a lot of tips are displayed here..."; text -l " - This script is designed to be used with the cameraMain script. Download it on www.highend3d.com"; text -l " - Open the mel file and read the header for more informations... "; text -l ""; text -al "right" -l "(c) Ced+Sapo, 30/11/2001 for the grain.S project."; setParent ..; showWindow; } //proc to go to the grainS web site.... global proc gotoUrl() { system("explorer http://grain.s.free.fr"); }