This file contains 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
melfunction.py | |
""" | |
Provides tools for wrapping mel commands for more Pythonic access. | |
Note this is a supplement to maya.cmds, not a replacement for it! This is intended to provide | |
similar coverage for un-translated MEL or commands fron plugins which don't respect the | |
ordinary cmds conventions. | |
Legalese: | |
This file contains 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
import maya,cmds as cmds | |
# All the command defined in the plugin show up in Maya.cmds if the plugin | |
# was loaded at startup.... | |
# alas, they don't work like the builtins..... | |
cmds.FBXExport(f = "path/to/file.fbx") | |
# RuntimeError: Use syntax: FBXExport -f "filename" [-s] |
This file contains 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
''' | |
FBXWrapper | |
This module provides a python wrapper for every method exposed in the FBX plugin. | |
The arguments for the calls are the same as for the equivalent mel calls, however they can be passed with typical | |
python syntax, which is translated to mel-style flags and arguments under the hood. The actual flags and arguments | |
are documented here: | |
usage: |
This file contains 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
import os | |
import shutil | |
import site | |
# source paths and local storage in environment vars | |
# switch toolsets by changing these before | |
# running maya | |
dist_file = os.environ['MAYA_TOOLS_SRC'] | |
maya_tools = os.environ['MAYA_TOOLS_LCL'] | |
last_mod_time = -1 |
This file contains 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
''' | |
This is the default UndeadLabs maya UserSetup.py. It should be copied into | |
one of the user's MAYA_SCRIPT_DIR folders (typically, the one for the | |
current version, like '2014x64', but it works in the generic one as well) | |
''' | |
import os | |
import site | |
import sys | |
ZIP_NAME = os.environ.get('MAYA_ZIP', 'ulmaya.zip') |
This file contains 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
""" | |
ul.paths.py | |
mimics the site module: process .pth files identically for zip and loose file distributions | |
""" | |
import zipfile | |
import sys | |
import os | |
import logging |
This file contains 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
sys.path_hooks.append(WebFinder) | |
sys.path.append("http://www.inference.phy.cam.ac.uk/mackay/python/compression/huffman") | |
# with the url on the path, just use import | |
import Example | |
print Example.__path__ | |
#['http://www.inference.phy.cam.ac.uk/mackay/python/compression/huffman/Example.py'] | |
# the module's __path__ will point at the url, but __file__ points at the cached | |
# file on disk |
This file contains 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
# usess the same imports as WebFinder.py | |
class WebLoader(object): | |
''' | |
Import loader (see http://pymotw.com/2/sys/imports.html for background) | |
which loads modules cached by a WebFinder using imp.load_source | |
''' | |
def __init__(self, url, filepath, name): | |
self.url = url | |
self.name = name |
This file contains 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
''' | |
web_shim.py | |
Exposes a custom module loader and importer which allow for download, cache and | |
load of python modules stored on an HTTP server | |
To activate, add the class to sys.path_hooks: | |
sys.path_hooks.append(WebFinder) | |
''' |
This file contains 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
''' | |
Exposes the MayaPyManager class, which is used to run instances of MayaPy with explict control over paths and environment variables. A Manager can run scripts, modules, or command strings in a separate MayaPy environment; results and errors are captured and returned. | |
Typical uses might be: | |
- running unit tests | |
- running a copy of Maya.standalone as a headless RPC server with StandaloneRPC https://github.com/theodox/standaloneRPC | |
- spawning multipe copies of maya to batch process files in parallel on a multi-core machine | |
- do any of the above on multiple maya versions concurrently |