// This procedue is a dummy procedure that will have whatIs run on it to determine where it was run from. global proc locate_script(){} // Run whatIs on our dummy procedure to determine where the script location is. global proc string script_location () { string $whatIs = `whatIs locate_script`; string $buffer[]; string $num_tokens = `tokenize $whatIs " " $buffer`; return $buffer[4]; } // 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(\"~\")"); if (`about -os` == "mac") { python("maya_module_directory = os.path.join(home, 'Library', 'Preferences', 'Autodesk', 'maya', 'modules')"); } else { python("maya_module_directory = os.path.join(home, 'maya', 'modules')"); } // 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:\ mod_dir = os.path.normpath(os.path.relpath(script_loc, maya_module_directory))\n\ except:\ mod_dir = script_loc"); // 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'"); // 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))"); // Load the plug-in. 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"`;