Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.42 KB | None | 0 0
  1. global proc BenBoxSA(){
  2. // BentoBox for Maya 2016 by Benjamin Kelly
  3. // Language: MEL
  4. // last updated: 03/30/2017
  5. // MHI-specific variant
  6.  
  7.  
  8. global string $BenBoxSA;
  9. if ( `window -exists $BenBoxSA` ){
  10. deleteUI -window $BenBoxSA;}
  11.  
  12. $BenBoxSA = `window -s off -mxb off -mnb off -tlb on -title "Bento Box" -widthHeight 152 282 -bgc 0.5 0.5 0.5 BentoBoxSA`;
  13. window -e -widthHeight 152 282 BentoBoxSA;
  14.  
  15. string $form = `formLayout`;
  16.  
  17. string $btnSepar = `button -label " Separate Assets" -bgc 0.95 0.6 0.4 -w 150 -h 28 -c "BB_SeparateAssets()"`;
  18. popupMenu -p $btnSepar;
  19. menuItem -bld 1 -l "Seperate Assets" -c "BB_SeparateAssets();";
  20. menuItem -d 1;
  21. menuItem -l "Help" -image "help.png" -c "infoBox(\"Separate Assets\");";
  22. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Separate Assets Commands\");";
  23. string $btnRender = `button -label " RenderCam" -bgc 0.3 0.65 0.98 -w 150 -h 28 -c "BB_RenderCam();"`;
  24. popupMenu -p $btnRender;
  25. menuItem -bld 1 -l "RenderCam" -c "BB_RenderCam();";
  26. menuItem -l " Select Camera" -c "BB_SelectCam();";
  27. menuItem -l " Isolate Select" -c "BB_IsolateSelect();";
  28. menuItem -l " PerspCam" -c "BB_PerspCam();";
  29. menuItem -d 1;
  30. menuItem -l "Help" -image "help.png" -c "infoBox(\"RenderCam\");";
  31. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"RenderCam Commands\");";
  32. string $btnStory = `button -label " Storyboard Control" -bgc 0.4 0.82 0.9 -w 150 -h 28 -c "BB_CamControl();"`;
  33. popupMenu -p $btnStory;
  34. menuItem -bld 1 -l "Storyboard Control" -c "BB_CamControl();";
  35. menuItem -d 1;
  36. menuItem -l "Help" -image "help.png" -c "infoBox(\"Storyboard Control\");";
  37. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Storyboard Control Commands\");";
  38. string $btnReuse = `button -label " Reuse Scene" -bgc 0.85 0.5 0.5 -w 150 -h 28 -c "BB_ReuseScene()"`;
  39. popupMenu -p $btnReuse;
  40. menuItem -bld 1 -l "Reuse Scene" -c "BB_ReuseScene();";
  41. menuItem -d 1;
  42. menuItem -l "Help" -image "help.png" -c "infoBox(\"Reuse Scene\");";
  43. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Reuse Scene Commands\");";
  44. string $btnGeoResA = `button -label " Geo Res" -bgc 0.45 0.45 0.67 -w 120 -h 28 -c "BB_HighRes(0);"`;
  45. popupMenu -p $btnGeoResA;
  46. menuItem -bld 1 -l "Geo Res" -c "BB_HighRes(0);";
  47. menuItem -l " Geo Res (All)" -c "BB_HighResALL();";
  48. menuItem -d 1;
  49. menuItem -l "Help" -image "help.png" -c "infoBox(\"Toggle Geo Res\");";
  50. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Geo Res Commands\");";
  51. string $btnGeoResB = `button -label " ALL" -bgc 0.39 0.39 0.61 -w 30 -h 28 -c "BB_HighResALL();"`;
  52. popupMenu -p $btnGeoResB;
  53. menuItem -bld 1 -l "Geo Res" -c "BB_HighRes(0);";
  54. menuItem -l " Geo Res (All)" -c "BB_HighResALL();";
  55. menuItem -d 1;
  56. menuItem -l "Help" -image "help.png" -c "infoBox(\"Toggle Geo Res\");";
  57. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Geo Res Commands\");";
  58. string $btnMass = `button -label " Mass Parent" -bgc 0.6 0.85 0.6 -w 150 -h 28 -c "BB_MassParent();"`;
  59. popupMenu -p $btnMass;
  60. menuItem -bld 1 -l "Mass Parent" -c "BB_MassParent();";
  61. menuItem -l " Add Rivet" -c "rivet();";
  62. menuItem -l " Create Locator on Spot" -c "BB_SpotLoc();";
  63. menuItem -d 1;
  64. menuItem -l "Help" -image "help.png" -c "infoBox(\"Mass Parent\");";
  65. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Mass Parent Commands\");";
  66. string $btnAlign = `button -label " Align" -bgc 0.8 0.75 0.4 -w 150 -h 28 -c "BB_Align();"`;
  67. popupMenu -p $btnAlign;
  68. menuItem -bld 1 -l "Align" -c "BB_Align();";
  69. menuItem -d 1;
  70. menuItem -l "Help" -image "help.png" -c "infoBox(\"Align\");";
  71. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Align Commands\");";
  72. string $btnShade = `button -label " Refresh Shader" -bgc 0.37 0.7 0.57 -w 150 -h 28 -c "BB_RefreshShader();"`;
  73. popupMenu -p $btnShade;
  74. menuItem -bld 1 -l "Refresh Shader" -c "BB_RefreshShader();";
  75. menuItem -d 1;
  76. menuItem -l "Help" -image "help.png" -c "infoBox(\"Refresh Shader\");";
  77. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Shader Commands\");";
  78. string $btnReset = `button -label " Reset Frame Count" -bgc 0.7 0.5 0.8 -w 150 -h 28 -c "BB_ResetFrameCount();"`;
  79. popupMenu -p $btnReset;
  80. menuItem -bld 1 -l "Reset Frame Count" -c "BB_ResetFrameCount();";
  81. menuItem -l " Add 10f to Start" -c "BB_AddFrameCount(\"st\");";
  82. menuItem -l " Add 10f to End" -c "BB_AddFrameCount(\"en\");";
  83. menuItem -d 1;
  84. menuItem -l "Help" -image "help.png" -c "infoBox(\"Reset Frame Count\");";
  85. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Frame Count Commands\");";
  86. string $btnClean = `button -label " Clean" -bgc 0.52 0.52 0.55 -w 80 -h 28 -c "BB_CleanScene();"`;
  87. // popupMenu -p $btnClean;
  88. //menuItem -bld 1 -l "Clean Workspace" -c "BB_CleanScene();";
  89. //menuItem -l " Load Workspace" -c "BB_LoadScene();";
  90. //menuItem -l " Save Workspace" -c "BB_SaveScene();";
  91. //menuItem -d 1;
  92. //menuItem -l "Help" -image "help.png" -c "infoBox(\"Clean Workspace\");";
  93. //menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Workspace Commands\");";
  94. string $btnLoad = `button -label " Load" -bgc 0.52 0.52 0.55 -w 70 -h 28 -c "BB_LoadScene();"`;
  95. popupMenu -p $btnLoad;
  96. //menuItem -bld 1 -l "Clean Workspace" -c "BB_CleanScene();";
  97. menuItem -bld 1 -l " Load Workspace" -c "BB_LoadScene();";
  98. menuItem -l " Save Workspace" -c "BB_SaveScene();";
  99. menuItem -d 1;
  100. menuItem -l "Help" -image "help.png" -c "infoBox(\"Clean Workspace\");";
  101. menuItem -itl 1 -l "Get MEL Commands..." -image "shelfTab.png" -c "infoBox(\"Workspace Commands\");";
  102.  
  103. string $imgSepar = `image -i "unconstrainedDrag.xpm" `;
  104. string $imgRender = `image -i "Camera.xpm" `;
  105. string $imgStory = `image -i "CameraAE.xpm" `;
  106. string $imgReuse = `image -i "redo_s.xpm" `;
  107. string $imgGeoRes = `image -i "out_layeredShader.xpm" `;
  108. string $imgMass = `image -i "copyUVMode.xpm" `;
  109. string $imgAlign = `image -i "out_pointLight.xpm" `;
  110. string $imgShade = `image -i "UseDefaultMaterial.xpm" `;
  111. string $imgReset = `image -i "FilmGate.xpm" `;
  112. string $imgClean = `image -i "clearAll.xpm" `;
  113. string $imgLoad = `image -i "currentNamespaceParent.xpm" `;
  114.  
  115.  
  116. formLayout -e
  117.  
  118. -af $imgSepar top 5
  119. -af $imgSepar left 5
  120. -af $btnSepar top 1
  121. -af $btnSepar left 1
  122.  
  123. -af $imgRender top 35
  124. -af $imgRender left 7
  125. -af $btnRender top 29
  126. -af $btnRender left 1
  127.  
  128. -af $imgStory top 64
  129. -af $imgStory left 7
  130. -af $btnStory top 57
  131. -af $btnStory left 1
  132.  
  133. -af $imgReuse top 89
  134. -af $imgReuse left 5
  135. -af $btnReuse top 85
  136. -af $btnReuse left 1
  137.  
  138. -af $imgGeoRes top 118
  139. -af $imgGeoRes left 5
  140. -af $btnGeoResA top 113
  141. -af $btnGeoResA left 1
  142. -af $btnGeoResB top 113
  143. -af $btnGeoResB left 121
  144.  
  145. -af $imgMass top 146
  146. -af $imgMass left 6
  147. -af $btnMass top 141
  148. -af $btnMass left 1
  149.  
  150. -af $imgAlign top 174
  151. -af $imgAlign left 5
  152. -af $btnAlign top 169
  153. -af $btnAlign left 1
  154.  
  155. -af $imgShade top 203
  156. -af $imgShade left 7
  157. -af $btnShade top 197
  158. -af $btnShade left 1
  159.  
  160. -af $imgReset top 231
  161. -af $imgReset left 7
  162. -af $btnReset top 225
  163. -af $btnReset left 1
  164.  
  165. -af $imgClean top 258
  166. -af $imgClean left 6
  167. -af $btnClean top 253
  168. -af $btnClean left 1
  169. -af $imgLoad top 361
  170. -af $imgLoad left 88
  171. -af $btnLoad top 253
  172. -af $btnLoad left 81
  173.  
  174. $form;
  175. showWindow $BenBoxSA;
  176.  
  177.  
  178. //fix Tween Machine
  179. if (`shelfButton -ex "shelf_anim_04_tween_machine_button"` == 1){shelfButton -e -stp "mel" -c "source \"B:/maya/current/src/mel/anim/tweenMachine.mel\"; tweenMachine;" "shelf_anim_04_tween_machine_button";}
  180.  
  181. }
  182.  
  183.  
  184. global proc infoBox(string $BBhelp){
  185. string $BBmessage;
  186. if ($BBhelp == "Separate Assets"){$BBmessage = "-- Separate Assets v1.2 --\n\n Spreads out all the assets clustered together at origin for easier selecting. \n Places each Transform_Ctrl in increments of 7 on the Translate X and Z.";}
  187. if ($BBhelp == "RenderCam"){$BBmessage = "-- RenderCam v2.0 --\n\n Creates a new window using the shot camera and hides control visibility. \n\n\n-- Select Camera -- \n\n Literally just selects the camera. Not everything is wizardry magic.\n\n\n-- Isolate Select --\n\n Isolates the selected asset in the current viewport.\n This version also retains the selected control.\n\n\n-- PerspCam --\n\n Creates a window using the persp camera.";}
  188. if ($BBhelp == "Storyboard Control"){$BBmessage = "-- Storyboard Control v1.3 --\n\n Creates a control box with a slider and toggle for the storyboard,\n and and a rule-of-thirds field guide toggle.\n\n Re-run the script upon opening a new scene to refresh the controls.";}
  189. if ($BBhelp == "Reuse Scene"){$BBmessage = "-- Reuse Scene v2.0 -- \n\n Changes the audio, storyboard, and frame count to the scene entered in the prompt.\n Be sure to use the proper format when entering the scene number.\n\n e.g: 321_032_001";}
  190. if ($BBhelp == "Toggle Geo Res"){$BBmessage = "-- Toggle Geo Res v4.0 -- \n\n Toggles between Proxy and High-res geo for selected objects. \n\n\n-- Toggle Geo Res (ALL) --\n\n Toggles geo resolution for all objects.";}
  191. if ($BBhelp == "Mass Parent"){$BBmessage = "-- Mass Parent v1.2 -- \n\n Parents multiple selected objects to a single object. \n Select the PARENT first and then all of the childrens.\n\n\n-- Rivet --\n\n Adds a locator between two selected edges that always stay attached to the geo. \n\n\n-- Create Locator on Spot --\n\n Creates a locator on the current selection.";}
  192. if ($BBhelp == "Align"){$BBmessage = "-- Align v2.0 -- \n\n If single object selected:\n - Aligns an object's Transform_Ctrl to its COG_Ctrl \n\n If multiple objects selected:\n - Aligns all selected objects to the first selected object";}
  193. if ($BBhelp == "Refresh Shader"){$BBmessage = "-- Refresh Shader v2.0 --\n\n Restores broken shader on selected geo until scene is closed.\n\n";}
  194. if ($BBhelp == "Reset Frame Count"){$BBmessage = "-- Reset Frame Count v1.1 -- \n\n Resets the frame count based on the audio length. \n\n\n-- Add 10f --\n\n Adds 10 frames of buffer to the start or end of a scene.";}
  195. if ($BBhelp == "Clean Workspace"){$BBmessage = "-- Clean Workspace v1.3--\n\n Preps scene for saving by closing all Maya panels and setting the display mode\n to wireframe.\n\n\n-- Load Workspace --\n\n Loads the workspace settings saved via the Save Workspace script.\n\n\n-- Save Workspace -- \n\n Saves the current viewport layout plus any floating windows and their positions. \n Excludes the Anim Library and some other BD Tools. \n\n (Will also save the AnimSchoolPicker if the plugin is loaded.)";}
  196.  
  197. if ($BBhelp == "Separate Assets Commands"){$BBmessage = "BB_SeparateAssets();";}
  198. if ($BBhelp == "RenderCam Commands"){$BBmessage = "BB_RenderCam();\nBB_SelectCam();\nBB_IsolateSelect();\nBB_PerspCam();";}
  199. if ($BBhelp == "Storyboard Control Commands"){$BBmessage = "BB_CamControl();\nBB_HighResALL;";}
  200. if ($BBhelp == "Geo Res Commands"){$BBmessage = "BB_HighRes(0);\nBB_HighResALL;";}
  201. if ($BBhelp == "Mass Parent Commands"){$BBmessage = "BB_MassParent();\nrivet();\nBB_SpotLoc();";}
  202. if ($BBhelp == "Align Commands"){$BBmessage = "BB_Align();";}
  203. if ($BBhelp == "Shader Commands"){$BBmessage = "BB_RefreshShader();";}
  204. if ($BBhelp == "Frame Count Commands"){$BBmessage = "BB_ResetFrameCount();\nBB_AddFrameCount(\"st\");\nBB_AddFrameCount(\"en\");";}
  205. if ($BBhelp == "Workspace Commands"){$BBmessage = "BB_CleanScene();\nBB_LoadScene();\nBB_SaveScene();";}
  206. confirmDialog -message $BBmessage -title $BBhelp -button "Okay";
  207. }
  208.  
  209. BenBoxSA;
  210.  
  211.  
  212.  
  213. global proc BB_SeparateAssets(){
  214. // -- Separate Assets --
  215. // Language: MEL
  216. // Version 1.2
  217. //
  218. // Spreads out all the assets clustered together at origin for easier selecting.
  219. // Places each Transform_Ctrl in increments of 7 on the Translate X and Z.
  220.  
  221. global int $sCount;
  222. global int $counterX = 0;
  223. global int $counterZ = 0;
  224. //Align all objects with :Transform_Ctrl
  225. if(`objExists "*:Transform_Ctrl"`){
  226. select -r "*:Transform_Ctrl";
  227. string $transList[] =`ls -selection`;
  228. //begin fix loop
  229. for($i = 0; $i < size($transList); $i = $i + 1){
  230. if ($transList[$i] == "VGT_IchabeezerMansion_INT:Transform_Ctrl"){}
  231. if ($transList[$i] == "VGT_KoiPond_EXT:Transform_Ctrl"){}
  232. if ($transList[$i] == "VGT_HumanNeighborhoodA_EXT:Transform_Ctrl"){}
  233. else {
  234. //get namespace by removing :Base_Ctrl from string
  235. int $ssA = 1;
  236. int $ssB = (`size($transList[$i])` - 15);
  237. $transList[$i] = `substring $transList[$i] $ssA $ssB`;
  238. setTranslate($transList[$i]);
  239. }
  240. }
  241. if ($sCount == 1){print ("1 asset separated. \n");}
  242. else {print ($sCount + " assets separated. \n");}
  243. } else {warning "No assets detected. \n";}
  244. select -cl ;
  245. $counterX = 0;
  246. $counterZ = 0;
  247. $sCount = 0;
  248. }
  249.  
  250. global proc setTranslate(string $ob) {
  251. global int $sCount;
  252. global int $counterX;
  253. global int $counterZ;
  254. if(`objExists ($ob + ":Transform_Ctrl")`) {
  255. //get true location relative to worldSpace
  256. float $wsArray[] = `xform -worldSpace -q -t ($ob + ":Transform_Ctrl")`;
  257. //if at origin, then move
  258. if ($wsArray[0] > -0.005 && $wsArray[0] < 0.005 && $wsArray[1] > -0.005 && $wsArray[1] < 0.005 && $wsArray[2] > -0.005 && $wsArray[2] < 0.005){
  259. setAttr ($ob + ":Transform_Ctrl.translateX") $counterX;
  260. setAttr ($ob + ":Transform_Ctrl.translateZ") $counterZ;
  261. $sCount++;
  262. //update movement counter
  263. $counterX = $counterX + 7;
  264. if ($counterX == 28) {
  265. $counterX = 0;
  266. $counterZ = $counterZ + 7;
  267. }
  268. }
  269. }
  270. }
  271.  
  272.  
  273.  
  274. global proc BB_RenderCam(){
  275. // -- RenderCam --
  276. // Language: MEL
  277. // Version 2.0
  278.  
  279. // Creates a new window using the shot camera and hides control visibility.
  280.  
  281. if(`objExists ("\*_Ren_CamRg_A:Render_Cam")`) {
  282. string $renCh = 0;
  283. if (`window -exists RenderCam`){deleteUI -window RenderCam; $renCh = 1;}
  284. if (`modelPanel -exists RenderCamPanel`){deleteUI -panel RenderCamPanel;}
  285. window -w 800 -h 600 "RenderCam";
  286. paneLayout;
  287. modelPanel -camera "\*_Ren_CamRg_A:Render_Cam" -l "RenderCamPanel" "RenderCamPanel";
  288. setFocus RenderCamPanel;
  289. displayStyle -ss;
  290. modelEditor -e -allObjects false RenderCamPanel;
  291. modelEditor -e -cameras true RenderCamPanel;
  292. modelEditor -e -imagePlane true RenderCamPanel;
  293. modelEditor -e -polymeshes true RenderCamPanel;
  294. modelEditor -e -grid false RenderCamPanel;
  295. string $currentPanel = `getPanel -withFocus`;
  296. string $currCam = `modelEditor -q -camera $currentPanel`;
  297. camera -e -displayResolution on -displayGateMask on -overscan 1.3 $currCam;
  298. showWindow RenderCam;
  299. if($renCh == 1){print "RenderCam window refreshed. \n";}
  300. else {print "RenderCam window created. \n";}
  301. } else {warning "Camera not detected. \n";}
  302. }
  303.  
  304. global proc BB_SelectCam(){
  305. // -- Select Camera --
  306. //
  307. // Literally just selects the camera. Not everything is wizardry magic.
  308.  
  309. if(`objExists "*Ren_CamRg_A:Render_Cam"`){select -r "*Ren_CamRg_A:Render_Cam";}
  310. else {warning "Camera not detected.";}
  311. }
  312.  
  313. global proc BB_IsolateSelect(){
  314. // -- Isolate Select --
  315. // Isolates the selected asset in the current viewport.
  316. // This version also retains the selected control.
  317.  
  318. saveSelect();
  319.  
  320. for($g = 0; $g < 30; $g = $g + 1){pickWalk -d up;}
  321.  
  322. $currentPanel = `getPanel -withFocus`;
  323. string $panelType = `getPanel -to $currentPanel`;
  324. if ($panelType == "modelPanel"){
  325. if (`isolateSelect -q -s $currentPanel` == 0){enableIsolateSelect $currentPanel true;}
  326. else {enableIsolateSelect $currentPanel false;}
  327. }
  328.  
  329. loadSelect();
  330. }
  331.  
  332. global proc BB_PerspCam(){
  333. // -- PerspCam --
  334. //
  335. // Creates a window using the persp camera.
  336.  
  337. string $renCh = 0;
  338. if (`window -exists PerspCam`){deleteUI -window PerspCam; $renCh = 1;}
  339. if (`modelPanel -exists PerspCamPanel`){deleteUI -panel PerspCamPanel;}
  340. window -w 800 -h 600 -t "PerspCam" "PerspCam";
  341. paneLayout;
  342. modelPanel -camera "persp" -l "PerspCamPanel" "PerspCamPanel";
  343. setFocus PerspCamPanel;
  344. showWindow PerspCam;
  345. if($renCh == 1){print "PerspCam window refreshed. \n";}
  346. else {print "PerspCam window created. \n";}
  347. }
  348.  
  349.  
  350.  
  351. global proc BB_CamControl(){
  352. // -- Storyboard Control --
  353. // Language: MEL
  354. // Version 1.3
  355. //
  356. // Creates a control box with a slider and toggle for the storyboard, and and a rule-of-thirds field guide toggle.
  357. // Re-run the script upon opening a new scene to refresh the controls.
  358.  
  359. if (`objExists imagePlane1` == 0){warning "Storyboards not detected."; return;}
  360. global string $alphaControl;
  361. float $alphagain1 = `getAttr ("imagePlane1.alphaGain")`;
  362. string $refCh = 0;
  363. if ( `window -exists $alphaControl` ){deleteUI -window $alphaControl; $refCh = 1;}
  364. $alphaControl = `window -sizeable off -mxb off -mnb off -tlb on -title "Storyboard Control" -widthHeight 180 184 AlphaControl`;
  365. window -e -widthHeight 180 119 AlphaControl;
  366. string $form = `formLayout`;
  367. global float $saved = 0;
  368. //Create slider
  369. string $label = `text -label "Storyboard Opacity" -align "right"`;
  370. string $toggle = `button -label "Toggle" -bgc 0.7 0.5 0.8 -w 168 -h 35 -c "lockUnlock();"`;
  371. string $fifty = `button -label "50%" -bgc 0.85 0.5 0.5 -w 84 -h 30 -c "alphaProc(0.5);"`;
  372. string $hundred = `button -label "100%" -bgc 0.6 0.8 0.6 -w 84 -h 30 -c "alphaProc(1);"`;
  373. string $field = `floatField -min 0.0 -max 1 -precision 2 -w 35`;
  374. string $slider = `floatSlider -min 0.0 -max 1 -enable false`;
  375. string $Ro3_label = `text -label "Rule of 3rds Field Guide" -align "right"`;
  376. string $Ro3_toggle = `button -label "Toggle" -bgc 0.4 0.7 0.9 -w 168 -h 35 -c "Ro3_lockUnlock();"`;
  377. //Connect to the controls
  378. connectControl $field ("imagePlane1.alphaGain");
  379. connectControl $slider ("imagePlane1.alphaGain");
  380. formLayout -e
  381. -af $field top 4
  382. -af $field left 6
  383. -af $slider top 8
  384. -ac $slider left 6
  385. $field -af $slider right 6
  386. -af $toggle top 78
  387. -af $toggle left 6
  388. -af $label top 27
  389. -af $label left 47
  390. -af $fifty top 45
  391. -af $fifty left 6
  392. -af $hundred top 45
  393. -af $hundred left 90
  394. -af $Ro3_label top 122
  395. -af $Ro3_label left 35
  396. -af $Ro3_toggle top 140
  397. -af $Ro3_toggle left 6
  398. $form;
  399. showWindow $alphaControl;
  400. if($refCh == 1){print "Storyboard Control window refreshed. \n";}
  401. else {print "Storyboard Control window created. \n";}
  402. }
  403.  
  404. global proc alphaProc(float $myAlpha){setAttr imagePlane1.alphaGain $myAlpha;}
  405.  
  406. global proc lockUnlock(){
  407. global float $saved;
  408. float $current = `getAttr "imagePlane1.alphaGain"`;
  409. if ($current == 0) {
  410. setAttr "imagePlane1.alphaGain" $saved;
  411. //setAttr "imagePlane1|imagePlaneShape1.useFrameExtension" 1;
  412. setAttr "imagePlaneShape1.useFrameExtension" 1;
  413. print "Use Image Sequence ON. \n";
  414. } else {
  415. $saved = `getAttr "imagePlane1.alphaGain"`;
  416. setAttr "imagePlane1.alphaGain" 0;
  417. //setAttr "imagePlane1|imagePlaneShape1.useFrameExtension" 0;
  418. setAttr "imagePlaneShape1.useFrameExtension" 0;
  419. print "Use Image Sequence OFF. \n";
  420. }
  421. }
  422.  
  423. global proc Ro3_lockUnlock(){
  424. if (`objExists "VGT_CC_Ro3_imagePlane"`) {select -r "VGT_CC_Ro3*"; doDelete; print "Ro3 Guide OFF. \n";}
  425. else {
  426. select -r |imagePlane1 ;
  427. duplicate -rr -n VGT_CC_Ro3_imagePlane;
  428. setAttr "VGT_CC_Ro3_imagePlane.depth" 0.1;
  429. setAttr -type "string" "VGT_CC_Ro3_imagePlane|VGT_CC_Ro3_imagePlaneShape.imageName" "T:/dwtv/vgt/Maya_VGT/scripts/BenScripts/Ro3_IMG.png";
  430. setAttr "VGT_CC_Ro3_imagePlaneShape.alphaGain" 1;
  431. select -cl;
  432. print "Ro3 Guide ON. \n";
  433. }
  434. }
  435.  
  436.  
  437.  
  438. global proc BB_ReuseScene(){
  439. // -- Reuse Scene Script --
  440. // Language: MEL
  441. // Version 2.0
  442. //
  443. // Changes the audio, storyboard, and frame count to the scene entered in the prompt.
  444. // Be sure to use the proper format when entering the scene number.
  445. //
  446. // e.g: 321_032_001
  447.  
  448. string $reuseResult = `promptDialog -title "Reuse Scene" -message "Enter Scene: (000_000_000)" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
  449. if ($reuseResult == "Cancel") {return;}
  450.  
  451. string $text = `promptDialog -query -text`;
  452. if (`size($text)` != 11 && `size($text)` != 12){warning "Invalid entry."; return;}
  453. else if (`substring $text 4 4` != "_"){warning "Invalid entry."; return;}
  454. string $rsounds[] = `ls -typ "audio"`;
  455. if (`size($rsounds)` < 1){warning "No audio detected.";}
  456. else if (`size($rsounds)` > 1){warning "More than one audio file detected. Please delete the extraneous audio and try again."; return;}
  457. else if (`objExists imagePlane1` == 0){warning "No storyboards detected."; return;}
  458. string $fn = `getAttr ($rsounds[0] + ".filename")`;
  459. string $sbfn = `getAttr imagePlane1.imageName`;
  460. string $show = `substring $rsounds[0] 1 3`;
  461. string $epi = `substring $rsounds[0] 5 7`;
  462. string $seq = `substring $rsounds[0] 9 (size($rsounds[0]))`;
  463. string $sea = `substring $text 1 1`;
  464. string $epiR = `substring $text 1 3`;
  465. string $seqR = `substring $text 5 (size($text))`;
  466. string $fnSub = `substitute ("S_0.*/" + $epi + "/" + $seq) $fn ("S_0" + $sea + "/" + $epiR + "/" + $seqR)`;
  467. string $fnR = `substitute $rsounds[0] $fnSub ($show + "_" + $text)`;
  468. string $sbSub = `substitute ("S_0.*/" + $epi + "/" + $seq) $sbfn ("S_0" + $sea + "/" + $epiR + "/" + $seqR)`;
  469. string $sbR = `substitute ($rsounds[0] + ".*") $sbSub ($show + "_" + $text)`;
  470. //audio
  471. if (`filetest -e $fnR` != 1){warning "Scene does not exist."; return;}
  472. delete $rsounds[0];
  473. file -i -type "audio" $fnR;
  474. //storyboards
  475. string $sbFin;
  476. if (`getAttr ($show + "_" + $text + ".duration")` >= 1000) {$sbFin = $sbR + ".0001.png";}
  477. else if (`getAttr ($show + "_" + $text + ".duration")` >= 100) {$sbFin = $sbR + ".001.png";}
  478. else if (`getAttr ($show + "_" + $text + ".duration")` >= 10) {$sbFin = $sbR + ".01.png";}
  479. else if (`getAttr ($show + "_" + $text + ".duration")` >= 1) {$sbFin = $sbR + ".1.png";}
  480. setAttr -type "string" imagePlane1.imageName $sbFin;
  481. BB_ResetFrameCount;
  482. print ("Loaded " + $text + ".");
  483. }
  484.  
  485.  
  486.  
  487. global proc BB_HighRes(string $char){
  488. // -- Toggle Geo Res --
  489. // Language: MEL
  490. // Version 4.0
  491. //
  492. // Toggles between Proxy and High-res geo for selected objects OR all characters.
  493.  
  494. global int $resTog;
  495. saveSelect();
  496. if ($char == 1){if(`objExists "*:Base_Ctrl"`){select -r "*:Base_Ctrl";}}
  497. string $geoList[] =`ls -selection`;
  498. if (size($geoList) == 0){warning "Nothing selected. \n";
  499. } else {
  500. if ($resTog == 0){
  501. if ($char ==1){print "Characters Geo set to Proxy. \n";} else {print "Geo set to Proxy. \n";}
  502. for($i = 0; $i < size($geoList); $i = $i + 1){
  503. select -r $geoList[$i];
  504. string $geoCheck[] = `ls -selection`;
  505. for($g = 0; $g < 20; $g = $g + 1){
  506. if(`attributeExists "GeoRes" ($geoCheck[0])`){
  507. $g = 20;
  508. $resTog = 1;
  509. string $qString[] = `attributeQuery -node ($geoCheck[0]) -le "GeoRes"`;
  510. if (`size $qString[0]` == 11) {
  511. setAttr ($geoCheck[0] + ".GeoRes") 1;
  512. }
  513. if (`size $qString[0]` == 17) {
  514. setAttr ($geoCheck[0] + ".GeoRes") 2;
  515. }
  516. } else {pickWalk -d up; $geoCheck = `ls -selection`;}
  517. }
  518. }
  519. } else {
  520. if ($char ==1){print "Characters Geo set to High-res. \n";} else {print "Geo set to High-res. \n";}
  521. for($i = 0; $i < size($geoList); $i = $i + 1){
  522. select -r $geoList[$i];
  523. string $geoCheck[] = `ls -selection`;
  524. for($g = 0; $g < 20; $g = $g + 1){
  525. if(`attributeExists "GeoRes" ($geoCheck[0])`){
  526. $g = 20;
  527. $resTog = 0;
  528. string $qString[] = `attributeQuery -node ($geoCheck[0]) -le "GeoRes"`;
  529. if (`size $qString[0]` == 11) {
  530. setAttr ($geoCheck[0] + ".GeoRes") 0;
  531. }
  532. if (`size $qString[0]` == 17) {
  533. setAttr ($geoCheck[0] + ".GeoRes") 0;
  534. }
  535. } else {pickWalk -d up; $geoCheck = `ls -selection`;}
  536. }
  537. }
  538. }
  539. }
  540. loadSelect();
  541. }
  542.  
  543. global proc BB_HighResALL(){
  544. // -- Toggle Geo Res (ALL) --
  545. //
  546. // Toggles geo resolution for all objects, excluding characters.
  547.  
  548. global int $resTog;
  549. saveSelect();
  550. select -cl;
  551. if(`attributeExists "GeoRes" "*Transform_Ctrl" `){select -add "*.GeoRes";}
  552. if(`attributeExists "GeoRes" "*:Transform_Ctrl" `){select -add "*:*.GeoRes";}
  553. if(`attributeExists "GeoRes" "*:*Transform_Ctrl" `){select -add "*:*.GeoRes";}
  554. if(`attributeExists "GeoRes" "*:*:Transform_Ctrl" `){select -add "*:*:*.GeoRes";}
  555. if(`attributeExists "GeoRes" "*:*:*Transform_Ctrl" `){select -add "*:*:*.GeoRes";}
  556. if(`attributeExists "GeoRes" "*:*:*:Transform_Ctrl" `){select -add "*:*:*:*.GeoRes";}
  557. if(`attributeExists "GeoRes" "*:*:*:*Transform_Ctrl" `){select -add "*:*:*:*.GeoRes";}
  558. if(`attributeExists "GeoRes" "*:*:*:*:Transform_Ctrl" `){select -add "*:*:*:*:*.GeoRes";}
  559. string $geoList[] =`ls -selection`;
  560. //check for and deselect characters by looking for base control
  561. for($i = 0; $i < size($geoList); $i = $i + 1){
  562. float $nameSize = `size $geoList[$i]`;
  563. float $nameSwitch = (float)$nameSize;
  564. string $nameCheck = `substring $geoList[$i] 1 ($nameSize - 14 - 7)`;
  565. if (`objExists ($nameCheck + "Base_Ctrl")`){select -d $geoList[$i];}
  566. }
  567. //Reload after characters deselected and toggle res
  568. string $geoList[] =`ls -selection`;
  569. if ($resTog == 0){
  570. print "All Geo set to High-res.";
  571. for($i = 0; $i < size($geoList); $i = $i + 1){setAttr $geoList[$i] 0;}
  572. $resTog = 1;
  573. } else {
  574. print "All Geo set to Proxy.";
  575. for($i = 0; $i < size($geoList); $i = $i + 1){setAttr $geoList[$i] 2;}
  576. $resTog = 0;
  577. }
  578. loadSelect();
  579. }
  580.  
  581. global proc saveSelect(){global string $saveSelect[]; string $saveSelect[] = `ls -selection`;}
  582. global proc loadSelect(){global string $saveSelect[]; select -r $saveSelect;}
  583.  
  584.  
  585.  
  586. global proc BB_MassParent(){
  587. // -- Mass Parent --
  588. // Language: MEL
  589. // Version 1.2
  590. //
  591. // Parents multiple selected objects to a single object.
  592. // Select the PARENT first and then all of the childrens.
  593.  
  594. string $obj[] = `ls -selection`;
  595. int $size = size($obj);
  596. for($i=1;$i<$size;++$i) {
  597. parentConstraint -mo $obj[0] $obj[$i];
  598. }
  599. if ($size <= 1) {warning "No objects selected.";}
  600. if ($size == 1) {warning "Only one object selected.";}
  601. if ($size == 2) {print ($obj[1] + " parented to " + $obj[0] + ". \n");}
  602. if ($size > 2) {print (($size - 1) + " objects parented to " + $obj[0] + ". \n");}
  603. }
  604.  
  605. global proc string rivet(){
  606. // Copyright (C) 2000-2001 Michael Bazhutkin - Copyright (C) 2000 studio Klassika
  607. // www.geocites.com/bazhutkin
  608. // bazhutkin@mail.ru
  609. //
  610. // Rivet (button) 1.0
  611. // Script File
  612. // MODIFY THIS AT YOUR OWN RISK
  613. //
  614. // Creation Date: April 13, 2001
  615. //
  616. //
  617. // Description:
  618. // Use "Rivet" to constrain locator to polygon or NURBS surfaces
  619. // Select two edges on polygon object
  620. // or select one point on NURBS surface and call rivet
  621. // Parent your rivets and buttons to this locator
  622.  
  623. // minor adjustments made
  624.  
  625. string $nameObject;
  626. string $namePOSI;
  627.  
  628. string $parts[];
  629. string $list[] = `filterExpand -sm 32`;
  630. int $size = size($list);
  631. if ($size > 0)
  632. {
  633. if ($size != 2)
  634. { warning("Please select two edges.");
  635. return "";
  636. }
  637.  
  638. tokenize($list[0],".",$parts);
  639. $nameObject = $parts[0];
  640. tokenize($list[0],"[]",$parts);
  641. float $e1 = $parts[1];
  642. tokenize($list[1],"[]",$parts);
  643. float $e2 = $parts[1];
  644.  
  645. string $nameCFME1 = `createNode curveFromMeshEdge -n "rivetCurveFromMeshEdge1"`;
  646. setAttr ".ihi" 1;
  647. setAttr ".ei[0]" $e1;
  648. string $nameCFME2 = `createNode curveFromMeshEdge -n "rivetCurveFromMeshEdge2"`;
  649. setAttr ".ihi" 1;
  650. setAttr ".ei[0]" $e2;
  651. string $nameLoft = `createNode loft -n "rivetLoft1"`;
  652. setAttr -s 2 ".ic";
  653. setAttr ".u" yes;
  654. setAttr ".rsn" yes;
  655.  
  656. $namePOSI = `createNode pointOnSurfaceInfo -n "rivetPointOnSurfaceInfo1"`;
  657. setAttr ".turnOnPercentage" 1;
  658. setAttr ".parameterU" 0.5;
  659. setAttr ".parameterV" 0.5;
  660.  
  661. connectAttr -f ($nameLoft + ".os") ($namePOSI + ".is");
  662. connectAttr ($nameCFME1 + ".oc") ($nameLoft + ".ic[0]");
  663. connectAttr ($nameCFME2 + ".oc") ($nameLoft + ".ic[1]");
  664. connectAttr ($nameObject + ".w") ($nameCFME1 + ".im");
  665. connectAttr ($nameObject + ".w") ($nameCFME2 + ".im");
  666. }
  667. else
  668. { $list = `filterExpand -sm 41`;
  669. $size = size($list);
  670.  
  671. if ($size > 0)
  672. {
  673. if ($size != 1)
  674. { error("No one point selected.");
  675. return "";
  676. }
  677. tokenize($list[0],".",$parts);
  678. $nameObject = $parts[0];
  679. tokenize($list[0],"[]",$parts);
  680. float $u = $parts[1];
  681. float $v = $parts[2];
  682. $namePOSI = `createNode pointOnSurfaceInfo -n "rivetPointOnSurfaceInfo1"`;
  683. setAttr ".turnOnPercentage" 0;
  684. setAttr ".parameterU" $u;
  685. setAttr ".parameterV" $v;
  686. connectAttr -f ($nameObject + ".ws") ($namePOSI + ".is");
  687. }
  688. else
  689. { warning("Please select two edges.");
  690. return "";
  691. }
  692. }
  693.  
  694. string $nameLocator = `createNode transform -n "rivet1"`;
  695. createNode locator -n ($nameLocator + "Shape") -p $nameLocator;
  696.  
  697. string $nameAC = `createNode aimConstraint -p $nameLocator -n ($nameLocator + "_rivetAimConstraint1")`;
  698. setAttr ".tg[0].tw" 1;
  699. setAttr ".a" -type "double3" 0 1 0;
  700. setAttr ".u" -type "double3" 0 0 1;
  701. setAttr -k off ".v";
  702. setAttr -k off ".tx";
  703. setAttr -k off ".ty";
  704. setAttr -k off ".tz";
  705. setAttr -k off ".rx";
  706. setAttr -k off ".ry";
  707. setAttr -k off ".rz";
  708. setAttr -k off ".sx";
  709. setAttr -k off ".sy";
  710. setAttr -k off ".sz";
  711.  
  712. connectAttr ($namePOSI + ".position") ($nameLocator + ".translate");
  713. connectAttr ($namePOSI + ".n") ($nameAC + ".tg[0].tt");
  714. connectAttr ($namePOSI + ".tv") ($nameAC + ".wu");
  715. connectAttr ($nameAC + ".crx") ($nameLocator + ".rx");
  716. connectAttr ($nameAC + ".cry") ($nameLocator + ".ry");
  717. connectAttr ($nameAC + ".crz") ($nameLocator + ".rz");
  718.  
  719. select -r $nameLocator;
  720. return ($nameLocator);
  721.  
  722. }
  723.  
  724. global proc BB_SpotLoc(){
  725. // -- Create Locator on Spot --
  726. //
  727. // Creates a locator on the current selection.
  728.  
  729. string $obj[] = `ls -selection`;
  730. if(`objExists $obj[0]`){
  731. spaceLocator -n "spotLoc0";
  732. scale -r 4 4 4;
  733. string $sL[] = `ls -selection`;
  734. parentConstraint -n "tmpSL" $obj[0] $sL[0];
  735. select -r "tmpSL";
  736. doDelete;
  737. select -cl;
  738. } else {
  739. spaceLocator -n "spotLoc0";
  740. scale -r 3 3 3;
  741. string $sL[] = `ls -selection`;
  742. parentConstraint -n "tmpSL" persp $sL[0];
  743. select -r "tmpSL";
  744. doDelete;
  745. select -r $sL[0];
  746. move -r -os -wd 0 0 -15;
  747. }
  748. print "Spot Locator created.\n";
  749. }
  750.  
  751.  
  752.  
  753. global proc BB_Align(){
  754. // -- Align --
  755. // Language: MEL
  756. // Version 3.1
  757. //
  758. // If single object selected:
  759. // - Aligns a character's ground controls to their Base_Ctrl
  760. // - Aligns a prop's Transform_Ctrl to its COG_Ctrl
  761.  
  762. // If multiple objects selected:
  763. // - Aligns all selected objects to the first selected object
  764.  
  765.  
  766. string $obj[] = `ls -selection`;
  767. if (`size($obj)` > 1){
  768. if(`objExists $obj[0]` && `objExists $obj[1]`){
  769. spaceLocator -n "alignLoc0";
  770. scale -r 4 4 4;
  771. string $sL[] = `ls -selection`;
  772. parentConstraint -n "tmpSL" $obj[0] $sL[0];
  773. delete "tmpSL";
  774. for($i = 1; $i < size($obj); $i = $i + 1){
  775. parentConstraint -n "tmpPar0" $sL[0] $obj[$i];
  776. int $saveKey = 0;
  777. int $curKey = `currentTime -q`;
  778. if (`selectKey -add -k -t $curKey $obj[$i]`){$saveKey = 1;}
  779. string $atrList[] = {"translateX","translateY","translateZ","rotateX","rotateY","rotateZ"};
  780. for($k = 0; $k < size($atrList); $k = $k + 1){
  781. float $vAtr = `getAttr ($obj[$i] + "." + $atrList[$k])`;
  782. setKeyframe -s 0 -attribute $atrList[$k] -hierarchy none $obj[$i];
  783. if ($saveKey == 0) {
  784. cutKey -s 0 -attribute $atrList[$k] -t $curKey $obj[$i];
  785. setAttr ($obj[$i] + "." + $atrList[$k]) $vAtr;
  786. }
  787. }
  788. select -r $sL[0]; select -add $obj[$i];
  789. parentConstraint -remove;
  790. }
  791. delete $sL[0];
  792. print ($obj[1] + " aligned to " + $obj[0] + ".\n");
  793. }
  794. } else {warning "Please select multiple objects.\n";}
  795. }
  796.  
  797.  
  798.  
  799. global proc BB_RefreshShader(){
  800. // -- Refresh Shader --
  801. // Language: MEL
  802. // Version 2.0
  803. //
  804. // Restores broken shader on selected geo until scene is closed.
  805.  
  806. string $reShader;
  807. string $shaList[] =`ls -selection`;
  808. if (`size($shaList)` == 0){warning "Please select a geometry object."; return;}
  809. for($i = 0; $i < size($shaList); $i = $i + 1){
  810. string $RelCheck[] = `listRelatives -type mesh $shaList[$i]`;
  811. if (`size($RelCheck)` > 0){
  812. string $myShapeNode[] = `listRelatives -children -shapes $shaList[$i]`;
  813. string $mySGs[] = `listConnections -type shadingEngine $myShapeNode[0]`;
  814. string $surfaceShader[] = `listConnections ($mySGs[0] + ".surfaceShader")`;
  815. string $reShader = $surfaceShader[0];
  816. select -r $shaList[$i];
  817. hyperShade -assign $reShader;
  818. select -cl;
  819. print ("Refreshed shader for " + $shaList[$i] + ".\n");
  820. } else {warning "Please select a geometry object.";}
  821. }
  822. select -r $shaList;
  823. }
  824.  
  825.  
  826.  
  827. global proc BB_ResetFrameCount(){
  828. // -- Reset Frame Count --
  829. // Language: MEL
  830. // Version 1.1
  831. //
  832. // Resets the frame count based on the audio length.
  833.  
  834. global string $gPlayBackSlider;
  835. string $sounds[] = `ls -typ "audio"`;
  836. if (`size($sounds)` == 0){warning "Audio not detected."; return;}
  837. playbackOptions -min 1 -ast 1 -max (`getAttr ($sounds[0] + ".duration")`) -aet (`getAttr ($sounds[0] + ".duration")`);
  838. timeControl -e -ds true -s $sounds[0] $gPlayBackSlider;
  839. }
  840.  
  841. global proc BB_AddFrameCount(string $where){
  842. // -- Add 10f --
  843. //
  844. // Adds 10 frames of buffer to the start or end of a scene.
  845.  
  846. global string $gPlayBackSlider;
  847. string $sounds[] = `ls -typ "audio"`;
  848. if (`size($sounds)` == 0){warning "Audio not detected."; return;}
  849. if($where == "st"){
  850. int $cur = `playbackOptions -q -min`;
  851. playbackOptions -min ($cur - 10) -ast ($cur - 10);
  852. }
  853. if($where == "en"){
  854. int $cur = `playbackOptions -q -max`;
  855. playbackOptions -max ($cur + 10) -aet ($cur + 10);
  856. }
  857. timeControl -e -ds true -s $sounds[0] $gPlayBackSlider;
  858. }
  859.  
  860.  
  861.  
  862. global proc BB_CleanScene(){
  863. // -- Clean Workspace STANDALONE OFFSHOOT --
  864. // Language: MEL
  865. // Version 1.3SA
  866.  
  867. // Preps scene for saving by closing all Maya panels and setting the display mode to wireframe.
  868.  
  869. print "\nClearing Workspace\n";
  870. print "----------\n";
  871. //execute Calista's python script to clear all panels
  872. camera -e -startupCamera true persp;
  873. setNamedPanelLayout "Four View";
  874. python ("import sys\n\ndef clear_panels():\n '''Description: Removes all panels and resets to default panels.\n Input: None\n Return: None'''\n default_panels = {'modelPanel1': 'Top View',\n 'modelPanel2': 'Side View',\n 'modelPanel3': 'Front View',\n 'modelPanel4': 'Persp View',\n 'outlinerPanel1': 'Outliner', \n 'graphEditor1': 'Graph Editor',\n 'dopeSheetPanel1': 'Dope Sheet',\n 'clipEditorPanel1': 'Trax Editor',\n 'sequenceEditorPanel1': 'Camera Sequencer',\n 'hyperGraphPanel1': 'Hypergraph Hierarchy',\n 'hyperShadePanel1': 'Hypershade',\n 'visorPanel1': 'Visor',\n 'nodeEditorPanel1': 'Node Editor',\n 'createNodePanel1': 'Create Node',\n 'polyTexturePlacementPanel1': 'UV Texture Editor',\n 'renderView': 'Render View',\n 'blendShapePanel1': 'Blend Shape',\n 'dynRelEdPanel1': 'Dynamic Relationships Editor',\n 'relationshipPanel1': 'Relationship Editor',\n 'referenceEditorPanel1': 'Reference Editor',\n 'componentEditorPanel1': 'Component Editor',\n 'dynPaintScriptedPanel': 'Paint Effects',\n 'scriptEditorPanel1': 'Script Editor'}\n default_layouts = set(['hyperGraphInfo', 'hyperGraphLayout'])\n\n\n p_names = set(default_panels.keys())\n panels = set(cmds.getPanel(allPanels=True))\n panels = list(panels.difference(p_names))\n p_num = 0\n for panel in panels:\n cmds.deleteUI(panel, panel=True)\n p_num += 1\n \n layouts = set(cmds.ls(type=['hyperView', 'hyperLayout', 'hyperGraphInfo']))\n layouts = list(layouts.difference(default_layouts))\n l_num = 0\n for layout in layouts:\n try:\n cmds.delete(layout)\n except:\n pass\n finally:\n l_num += 1\n \n msg = '%i panels / %i layouts deleted' % (p_num, l_num)\n \n #Rebuild model panels if missing\n model_panels = ['modelPanel1','modelPanel2','modelPanel3','modelPanel4']\n gMainPane = mel.eval\('global string $gMainPane; $temp = $gMainPane;')\n for m_panel in model_panels:\n if not cmds.modelPanel(m_panel, exists=True):\n cmds.modelPanel(m_panel, parent=gMainPane)\n \n for name, label in default_panels.items():\n try:\n cmds.panel(name, e=True, label=label)\n except:\n pass\n\n\n mel.eval('lookThroughModelPanel top modelPanel1')\n mel.eval('lookThroughModelPanel side modelPanel2')\n mel.eval('lookThroughModelPanel front modelPanel3')\n mel.eval('lookThroughModelPanel persp modelPanel4')\n mel.eval('setNamedPanelLayout \"Single Perspective View\"')\n return msg\n \n \n#clean_scene()\n#clear_refs()\n#clear_groupID()\nclear_panels()\nsys.exit");
  875. global string $gMainWindow;
  876. string $allOpenWindows[] = `lsUI -wnd`;
  877. //clear all other windows
  878. for($i = 0; $i < size($allOpenWindows); $i = $i + 1){
  879. if ($allOpenWindows[$i] == "MayaWindow"){}
  880. else {
  881. if ($allOpenWindows[$i] == "BentoBoxSA"){}
  882. else {
  883. deleteUI ($allOpenWindows[$i]);
  884. print ("Cleared " + $allOpenWindows[$i] + ".\n");
  885. }
  886. }
  887. }
  888.  
  889. //set display to wireframe
  890. string $pans[] = `getPanel -type modelPanel`;
  891. int $size = size($pans);
  892. for($i=1;$i<$size;++$i) {
  893. setFocus $pans[$i];
  894. displayStyle -wireframe ;
  895. }
  896. setNamedPanelLayout "Single Perspective View";
  897. setFocus modelPanel4;
  898. print "----------\n";
  899. print "Workspace cleared.\n";
  900. }
  901.  
  902. global proc BB_LoadScene(){
  903. // -- Load Workspace --
  904. //
  905. // Loads the workspace settings saved via the Save Workspace script.
  906. $fileName = ( `internalVar -userScriptDir` + "layout.cfg" );
  907. if(`filetest -e $fileName` == 0){ warning "No workspace saved. Please save your workspace by right-clicking the Load button and selecting \"Save Workspace\"."; return;}
  908. $fileId=`fopen $fileName "r"`;
  909. string $layoutName = `fgetline $fileId`;
  910. string $ifRender = `fgetline $fileId`;
  911. string $ifStory = `fgetline $fileId`;
  912. string $ifGraph = `fgetline $fileId`;
  913. string $ifDope = `fgetline $fileId`;
  914. string $ifTrax = `fgetline $fileId`;
  915. string $ifOut = `fgetline $fileId`;
  916. string $ifHop = `fgetline $fileId`;
  917. string $ifRef = `fgetline $fileId`;
  918. string $ifTween = `fgetline $fileId`;
  919. string $ifVGTP = `fgetline $fileId`;
  920. string $ifPAIE = `fgetline $fileId`;
  921. string $ifGhost = `fgetline $fileId`;
  922. string $ifTang = `fgetline $fileId`;
  923. string $ifANIP = `fgetline $fileId`;
  924. string $ifANIP_path = `fgetline $fileId`;
  925. string $ifPersp = `fgetline $fileId`;
  926. fclose $fileId;
  927. //string $plugList[] = `pluginInfo -q -ls`;
  928. //for ($i = 0; $i < size($plugList); $i++) { if(`pluginInfo -q -n $plugList[$i]` == "AnimSchoolPicker"){$ifANIP = 1;}}
  929. int $nameCut = `size($layoutName)` - 1;
  930. string $cutName = `substring $layoutName 1 $nameCut`;
  931. setNamedPanelLayout $cutName;
  932. print "\n---Windows Loaded---\n";
  933. if($ifRender == "1\n"){BB_RenderCam(); print "RenderCam\n";}
  934. if($ifStory == "1\n"){BB_CamControl(); print "Storyboard Control\n";}
  935. if($ifGraph == "1\n"){GraphEditor; print "Graph Editor\n";}
  936. if($ifDope == "1\n"){DopeSheetEditor; print "Dope Sheet\n";}
  937. if($ifTrax == "1\n"){CharacterAnimationEditor; print "Trax Editor\n";}
  938. if($ifOut == "1\n"){OutlinerWindow; print "Outliner\n";}
  939. if($ifHop == "1\n"){
  940. //if(`window -ex "hopWin"`){deleteUI -window "hopWin";}
  941. //source "hop.mel";source "as_infoInScene.mel";source "chop.mel";source "getPreUnder.mel";source "tungsethTangent.mel";hop;
  942. //print "Hop Tool\n";
  943. }
  944. if($ifRef == "1\n"){ReferenceEditor; print "Reference Editor\n";}
  945. if($ifTween == "1\n"){source "B:/maya/current/src/mel/anim/tweenMachine.mel"; tweenMachine; print "Tween Machine \n";}
  946. if($ifVGTP == "1\n"){python "from vgt_anim_picker import vgt_anim_picker; reload(vgt_anim_picker); sys.exit;"; print "VGT Picker\n";}
  947. if($ifPAIE == "1\n"){python "paie.GUI(); sys.exit;"; print "PAIE\n";}
  948. if($ifGhost == "1\n"){bhGhost(); print "Ghost Tool\n";}
  949. if($ifTang == "1\n"){autoTangent(); print "AutoTangent\n";}
  950. if($ifANIP == "1\n"){
  951. string $plugLoad = 0;
  952. string $plugList[] = `pluginInfo -q -ls`;
  953. for ($i = 0; $i < size($plugList); $i++) {
  954. if(`pluginInfo -q -n $plugList[$i]` == "AnimSchoolPicker"){
  955. if (`exists AnimSchoolPicker`) {AnimSchoolPicker();}
  956. if (`exists CharacterPicker`) {CharacterPicker();}
  957. $plugLoad = 1;
  958. }
  959. }
  960. if ($plugLoad == 0){
  961. loadPlugin -qt $ifANIP_path;
  962. if (`exists AnimSchoolPicker`) {AnimSchoolPicker();}
  963. if (`exists CharacterPicker`) {CharacterPicker();}
  964. }
  965. print "AnimSchoolPicker\n";
  966. }
  967. if($ifPersp == "1\n"){BB_PerspCam(); print "PerspCam\n";}
  968. print ("\nLoaded \"" + $cutName + "\" workspace.\n");
  969. }
  970.  
  971. global proc BB_SaveScene(){
  972. // -- Save Workspace --
  973. //
  974. // Saves the current viewport layout plus any floating windows and their positions.
  975. // Excludes the Anim Library and some other BD Tools.
  976. //
  977. // (Will also save the AnimSchoolPicker if the plugin is loaded.)
  978.  
  979. global string $gMainWindow;
  980. global string $gMainPane;
  981. global string $gPanelEditorWnd;
  982. string $text = "New Layout";
  983. string $layoutName = "";
  984. string $config, $configArray[];
  985.  
  986. string $OK = (uiRes("m_saveCurrentPanelLayout.kOk"));
  987. string $cancel = (uiRes("m_saveCurrentPanelLayout.kCancel"));
  988.  
  989. string $result = `promptDialog
  990. -title (uiRes("m_saveCurrentPanelLayout.kSavePanelArrangement"))
  991. -message (uiRes("m_saveCurrentPanelLayout.kEnterName"))
  992. -text $text
  993. -button $OK
  994. -button $cancel
  995. -defaultButton $OK
  996. -cancelButton $cancel
  997. -dismissString $cancel
  998. -parent $gMainWindow`;
  999.  
  1000. //
  1001. // If the result was "OK", then proceed
  1002. //
  1003. if ( $result == $OK ) {
  1004.  
  1005. $layoutName = `promptDialog -query`;
  1006.  
  1007. // First check if the name is unique.
  1008. //
  1009. $configArray = `getPanel -allConfigs`;
  1010. for ($config in $configArray) {
  1011. if ($layoutName == `panelConfiguration -query -label $config`) {
  1012.  
  1013. string $str = (uiRes("m_saveCurrentPanelLayout.kConfirmDlgMsg"));
  1014. string $msg = `format -s $layoutName $str`;
  1015. confirmDialog
  1016. -title (uiRes("m_saveCurrentPanelLayout.kWarning"))
  1017. -message $msg
  1018. -button (uiRes("m_saveCurrentPanelLayout.kClose"))
  1019. -parent $gMainWindow;
  1020. return;
  1021. }
  1022. }
  1023.  
  1024. string $newConfigName = `panelConfiguration -sc false`;
  1025. panelConfiguration -edit -label $layoutName $newConfigName;
  1026. updatePanelLayoutFromCurrent $layoutName;
  1027. //check for windows
  1028. string $ifRender = 0;
  1029. if (`window -ex "RenderCam"` && `window -q -vis "RenderCam"` == 1){$ifRender = 1;}
  1030. string $ifStory = 0;
  1031. if (`window -ex "AlphaControl"` && `window -q -vis "AlphaControl"` == 1){$ifStory = 1;}
  1032. string $ifGraph = 0;
  1033. if (`window -ex "graphEditor1Window"` && `window -q -vis "graphEditor1Window"` == 1){$ifGraph = 1;}
  1034. string $ifDope = 0;
  1035. if (`window -ex "dopeSheetPanel1Window"` && `window -q -vis "dopeSheetPanel1Window"` == 1){$ifDope = 1;}
  1036. string $ifTrax = 0;
  1037. if (`window -ex "clipEditorPanel1Window"` && `window -q -vis "clipEditorPanel1Window"` == 1){$ifTrax = 1;}
  1038. string $ifOut = 0;
  1039. if (`window -ex "outlinerPanel1Window"` && `window -q -vis "outlinerPanel1Window"` == 1){$ifOut = 1;}
  1040. string $ifHop = 0;
  1041. if (`window -ex "hopWin"` && `window -q -vis "hopWin"` == 1){$ifHop = 1;}
  1042. string $ifRef = 0;
  1043. if (`window -ex "referenceEditorPanel1Window"` && `window -q -vis "referenceEditorPanel1Window"` == 1){$ifRef = 1;}
  1044. string $ifTween = 0;
  1045. //if (`window -ex "tweenMachineWin"` && `window -q -vis "tweenMachineWin"` == 1){$ifTween = 1;}
  1046. string $ifVGTP = 0;
  1047. if (`window -ex "meltGui"` && `window -q -vis "meltGui"` == 1){$ifVGTP = 1;}
  1048. string $ifPAIE = 0;
  1049. if (`window -ex "PaieGUI"` && `window -q -vis "PaieGUI"` == 1){$ifPAIE = 1;}
  1050. string $ifGhost = 0;
  1051. if (`window -ex "bhGhost"` && `window -q -vis "bhGhost"` == 1){$ifAnim = 1;}
  1052. string $ifTang = 0;
  1053. if (`window -ex "autoTangentWin"` && `window -q -vis "autoTangentWin"` == 1){$ifTang = 1;}
  1054. string $ifANIP = 0;
  1055. string $ifANIP_path = "none";
  1056. string $plugList[] = `pluginInfo -q -ls`;
  1057. for ($i = 0; $i < size($plugList); $i++) {
  1058. if(`pluginInfo -q -n $plugList[$i]` == "AnimSchoolPicker"){
  1059. $ifANIP = 1;
  1060. $ifANIP_path = `pluginInfo -q -p $plugList[$i]`;
  1061. }
  1062. }
  1063. string $ifPersp = 0;
  1064. if (`window -ex "PerspCam"` && `window -q -vis "PerspCam"` == 1){$ifPersp = 1;}
  1065. $fileName = ( `internalVar -userScriptDir` + "layout.cfg" );
  1066. $fileId=`fopen $fileName "w"`;
  1067. fprint $fileId ($layoutName + "\n");
  1068. fprint $fileId ($ifRender + "\n");
  1069. fprint $fileId ($ifStory + "\n");
  1070. fprint $fileId ($ifGraph + "\n");
  1071. fprint $fileId ($ifDope + "\n");
  1072. fprint $fileId ($ifTrax + "\n");
  1073. fprint $fileId ($ifOut + "\n");
  1074. fprint $fileId ($ifHop + "\n");
  1075. fprint $fileId ($ifRef + "\n");
  1076. fprint $fileId ($ifTween + "\n");
  1077. fprint $fileId ($ifVGTP + "\n");
  1078. fprint $fileId ($ifPAIE + "\n");
  1079. fprint $fileId ($ifGhost + "\n");
  1080. fprint $fileId ($ifTang + "\n");
  1081. fprint $fileId ($ifANIP + "\n");
  1082. fprint $fileId ($ifANIP_path + "\n");
  1083. fprint $fileId ($ifPersp + "\n");
  1084. fclose $fileId;
  1085.  
  1086. // special case for top,front,side,persp
  1087. // -make sure they always reset their state.
  1088. //
  1089. int $i,$nArr;
  1090. string $labels[];
  1091. $labels = `panelConfiguration -q -labelStrings $newConfigName`;
  1092. $nArr = size($labels);
  1093. for ($i = 0; $i < $nArr; $i++) {
  1094. if (localizedPanelLabel("Persp View") == $labels[$i] ||
  1095. localizedPanelLabel("Top View") == $labels[$i] ||
  1096. localizedPanelLabel("Side View") == $labels[$i] ||
  1097. localizedPanelLabel("Front View") == $labels[$i])
  1098. {
  1099. panelConfiguration -e -rfs ($i+1) true $newConfigName;
  1100. }
  1101. }
  1102. }
  1103. //int $nameCut = `size($layoutName)` - 1;
  1104. //string $cutName = `substring $layoutName 1 $nameCut`;
  1105. print ("\nSaved \"" + $layoutName + "\" workspace.\n");
  1106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement