Monday 2 November 2009

reinitialise setup machine menu script

if (`objExists TSM2FKIKSwitch`)
delete TSM2FKIKSwitch;
if (`menu -exists TSM2ControlsMenu`) deleteUI -menu TSM2ControlsMenu;

string $path = `pluginInfo -q -path "TSM2"`;
$path = (dirname($path) + "/TSM2/FKIK.mel");
int $file = `fopen $path "r"`;
string $fkikScript = "";
string $nextLine = `fgetline $file`;
while(size($nextLine) > 0) {
$fkikScript += $nextLine;
$nextLine = `fgetline $file`;
}
fclose $file;
$path = `pluginInfo -q -path "TSM2"`;
$path = (dirname($path) + "/TSM2/TSM2_mirrorPose.mel");
int $file = `fopen $path "r"`;
string $mirrorScript = "";
string $nextLine = `fgetline $file`;
while(size($nextLine) > 0) {
$mirrorScript += $nextLine;
$nextLine = `fgetline $file`;
}
fclose $file;
$mirrorScript += "\n\nTSM2_mirrorPose;";
string $afterScript = "if (`menu -exists TSM2ControlsMenu`) deleteUI -menu TSM2ControlsMenu";
string $beforeScript;
$beforeScript = "doEnableNodeItems false all; doEnableNodeItems true all;\n";
$beforeScript += "menu -to true -label \"TSM Controls\" -parent $gMainWindow TSM2ControlsMenu;";
$beforeScript += ("menuItem -label \"FKIK Switch\" -command \"" + (encodeString($fkikScript)) + "\";");
$beforeScript += ("menuItem -label \"Refresh Rig\" -command \"doEnableNodeItems false all; doEnableNodeItems true all;\";");
$beforeScript += ("menuItem -label \"Mirror Pose\" -command \"" + (encodeString($mirrorScript)) + "\";");
scriptNode -st 2 -bs $beforeScript -as $afterScript -n TSM2FKIKSwitch;
scriptNode -executeBefore TSM2FKIKSwitch;