/
install.mel
43 lines (35 loc) · 1.35 KB
/
install.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
string $subDir = "MayaViewportCapture/";
string $scriptName="MayaViewportCapture";
string $ImagePath = "/icon/icon" ;
string $iconExt="png";
string $label="cap";
global string $gShelfTopLevel;
string $currentShelf = `tabLayout -query -selectTab $gShelfTopLevel`;
setParent $currentShelf;
string $asInstallScriptLocation=`asInstallScriptLocation`;
string $command= "import sys\n\nLibrary_DIR = r\"" + $asInstallScriptLocation + $subDir + "\"\n\nif not Library_DIR in sys.path:\n sys.path.append(Library_DIR)\n\nimport ViewportCapture\nreload(ViewportCapture)\n\ncapture_tool = ViewportCapture.mayaWin()";
string $icon=$asInstallScriptLocation + $subDir + $ImagePath + "." +$iconExt;
shelfButton
-command $command
-annotation $scriptName
-label $scriptName
-image $icon
-image1 $icon
-sourceType "python"
-imageOverlayLabel $label
;
global proc asInstallScriptLocator (){}
global proc string asInstallScriptLocation ()
{
string $whatIs=`whatIs asInstallScriptLocator`;
string $fullPath=`substring $whatIs 25 999`;
string $buffer[];
string $slash="/";
if (`gmatch $whatIs "*\\\*"`)//sourced from ScriptEditor
$slash="\\";
int $numTok=`tokenize $fullPath $slash $buffer`;
int $numLetters=size($fullPath);
int $numLettersLastFolder=size($buffer[$numTok-1]);
string $scriptLocation=`substring $fullPath 1 ($numLetters-$numLettersLastFolder)`;
return $scriptLocation;
}