diff options
| author | home_pc <[email protected]> | 2020-01-20 13:48:51 -0800 |
|---|---|---|
| committer | home_pc <[email protected]> | 2020-01-20 13:48:51 -0800 |
| commit | 75fa1d1810e98453960a81115d88302e276d817f (patch) | |
| tree | 92f37accb3cb041d056d00525b5830a69862631a /install.mel | |
| parent | fixed install.mel issue (diff) | |
| download | artv2-75fa1d1810e98453960a81115d88302e276d817f.tar.xz artv2-75fa1d1810e98453960a81115d88302e276d817f.zip | |
Uploading work on refactor
At this point, all components can build their skeletons. Next steps are to get components building their rigs.
Diffstat (limited to 'install.mel')
| -rw-r--r-- | install.mel | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/install.mel b/install.mel index 36c4c16..f62302f 100644 --- a/install.mel +++ b/install.mel @@ -1,65 +1,64 @@ -// This script installs and loads the ARTv2 plugin, and configures it to load automatically. -// To run, open the Script Editor and Source the file. +// This procedue is a dummy procedure that will have whatIs run on it to determine where it was run from. +global proc locate_script(){} - -// ---- GLOBAL PROCEDURES ---- - -// Dummy procedure used to locate the source script file path -global proc scriptLocator (){} - -// Return path to directory containing this script -global proc string scriptLocation () +// Run whatIs on our dummy procedure to determine where the script location is. +global proc string script_location () { - string $whatIs=`whatIs scriptLocator`; - string $fullPath=`substring $whatIs 25 999`; // Strip the human-readable preamble before the file path - python("import os"); // Just in case this hasn't been imported already by some other scope - return python("os.path.dirname('" + $fullPath + "')"); + string $whatIs = `whatIs locate_script`; + string $buffer[]; + string $num_tokens = `tokenize $whatIs " " $buffer`; + return $buffer[4]; } -// ---- INSTALLATION SCRIPT ---- - -string $scriptLocation = scriptLocation(); +// Get the script location. +string $script_path = script_location(); +// Find maya module directory based on operating system. python("import os"); python("home = os.path.expanduser(\"~\")"); -// Generate platform-relevant path to user's Maya modules directory. if (`about -os` == "mac") { - python("mayaModDir = os.path.join(home, 'Library', 'Preferences', 'Autodesk', 'maya', 'modules'"); + python("maya_module_directory = os.path.join(home, 'Library', 'Preferences', 'Autodesk', 'maya', 'modules')"); } else { - python("mayaModDir = os.path.join(home, 'maya', 'modules')"); + python("maya_module_directory = os.path.join(home, 'maya', 'modules')"); } -python("scriptLoc = '" + $scriptLocation + "'"); -// Attempt to generate relative path to the script, otherwise use the install script's location -// NB: This is formatted to look like 4 lines, but it's actually a single -// string containing 2 logical lines manually broken with \n +// This is the default maya module directory location. +python("maya_module_directory = os.path.normpath(maya_module_directory)"); + +// Find the relative path of the script in relation to the maya module directory. +python("script_loc = os.path.dirname('" + $script_path + "'" + ")"); + python("try:\ - modDir = os.path.normpath(os.path.relpath(scriptLoc, mayaModDir))\n\ + mod_dir = os.path.normpath(os.path.relpath(script_loc, maya_module_directory))\n\ except:\ - modDir = scriptLoc"); - -// Set up names and paths for generating the module file -python("modName = 'ARTv2'"); -python("modFileName = modName + '.mod'"); -python("modFile = os.path.join(scriptLoc, modFileName)"); -python("newModFile = os.path.join(mayaModDir, modFileName)"); -python("replace_str = 'REPLACE_TO_YOUR_PATH'"); + mod_dir = script_loc"); -// Create new module file from template -python("if not os.path.exists(mayaModDir): os.makedirs(mayaModDir)"); -python("with open(modFile, 'r') as f: template = f.read()"); -python("with open(newModFile, 'w') as f: f.write(template.replace(replace_str, modDir))"); +// Build relevant path data for creating the module file +python("mod_name = 'ARTv2'"); +python("mod_file_name = mod_name + '.mod'"); +python("mod_file = os.path.join(script_loc, mod_file_name)"); +python("new_mod_file = os.path.join(maya_module_directory, mod_file_name)"); +python("replace_string = 'REPLACE_TO_YOUR_PATH'"); -// Load plugin and set to auto-load +// Create new module file from the template file. +python("if not os.path.exists(maya_module_directory): os.makedirs(maya_module_directory)"); +python("with open(mod_file, 'r') as f: template = f.read()"); +python("with open(new_mod_file, 'w') as f: f.write(template.replace(replace_string, mod_dir))"); -loadModule -ld `python("newModFile")`; +// Load the plug-in. -string $result = `confirmDialog -title "ARTv2" -message "ARTv2 installed! Maya will now close.\nPlease restart Maya \ -and load the ARTv2 plugin\n(set auto-load as well!) and follow the prompts." - -button "Finish"`; -quit -force;
\ No newline at end of file +python("import json"); +python("module_paths = os.environ['MAYA_PLUG_IN_PATH']"); +python("module_paths += ';'"); +python("module_paths += os.path.join(script_loc, 'plug-ins')"); +python("os.environ['MAYA_PLUG_IN_PATH'] = module_paths"); +rehash; +loadPlugin "artv2.py"; +pluginInfo -edit -autoload 1 "artv2.py"; +// Report to user +string $result = `confirmDialog -title "ARTv2" -message "ARTv2 has been installed." -button "Finish"`;
\ No newline at end of file |