-
Notifications
You must be signed in to change notification settings - Fork 18
/
setup.mel
51 lines (41 loc) · 1.25 KB
/
setup.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
43
44
45
46
47
48
49
50
51
// Installs the OBB package to your open maya session.
proc string getPathFromProc(string $procName)
{
string $whatIs = `whatIs $procName`;
string $parts[] = `stringToStringArray $whatIs ":"`;
// in case something went wrong:
if (size($parts) == 1)
return $parts[0];
// else if there are 2 items the second is the path:
string $path = $parts[1];
// or more than 2 the ":" separated them: reattach
if (size($parts) > 2)
for ($i = 2; $i < size($parts); $i++)
$path += ":" + $parts[$i];
return strip($path);
}
global proc setupOBB()
{
string $path = `getPathFromProc "setupOBB"`;
string $dirPath = dirname($path);
string $userScriptDir = `internalVar -userScriptDir`;
if (`file -q -ex ($userScriptDir + "OBB")`)
{
string $response = `confirmDialog -t "Reinstall?" -m "Would you like to reinstall OBB?" -button "Yes" -button "No" -dismissString "No"`;
if ($response == "Yes")
{
python "import shutil";
python ("shutil.rmtree(\"" + $userScriptDir + "OBB\")");
}
else
{
return;
}
}
// Copy the file path.
python "import shutil";
python ("shutil.copytree(\"" + $dirPath + "/OBB\", \"" + $userScriptDir + "/OBB\")");
python "import OBB.shelf";
confirmDialog -t "Installed" -m "OBB has been installed!" -button "Okay";
}
setupOBB();