Created
August 31, 2024 07:55
-
-
Save justsh/920fb5b9abfb34d72109704cf643bcd2 to your computer and use it in GitHub Desktop.
Workaround userSetup file for viz/pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // HACK: Workaround since a maya project's scripts folder is not added | |
| // to the PYTHONPATH by default | |
| // WARN: only one userSetup.mel is loaded. | |
| // using this script will prevent several viz scripts from running | |
| // Github issue has been logged and will be resolved on the viz/pipeline end | |
| // given that a userSetup script should be available to... well, users. | |
| // HACK: sourcing a mel file that sources other files is known to cause | |
| // issues. See maya documentation: | |
| // http://download.autodesk.com/global/docs/maya2012/en_us/Commands/source.html | |
| print "loading viz menu manually"; | |
| source "/usr/aw/local/userSetup.mel"; | |
| print "adding project scripts/ dir to python sys.path\n"; | |
| string $workspace_path = `workspace -q -rd`; | |
| string $workspace_scripts = `workspace -q -fre "scripts"`; | |
| string $script_path = $workspace_path + $workspace_scripts; | |
| string $userSetupPy = $script_path + "/" + "userSetup.py"; | |
| // NOTE: the string must start on the same line | |
| string $py_script = `format -stringArg $script_path -stringArg $userSetupPy "\ | |
| import sys\n\ | |
| if \"^1s\" not in sys.path: \n\ | |
| sys.path.insert(0, \"^1s\")\n\ | |
| \n\ | |
| try:\n\ | |
| execfile(\"^2s\")\n\ | |
| except Exception as e:\n\ | |
| print(\"Could not autoload userSetup.py\")\n\ | |
| print(e)\ | |
| "`; | |
| python($py_script); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment