mgear.core.utils module
Utilitie functions
- mgear.core.utils.as_pynode(obj)
Check and convert a given string to Pynode
If the object is not str or unicode or PyNode will raise type error
- Parameters:
obj (str, unicode, PyNode) – Object to check and/or convert to PyNode
- Returns:
the pynode object
- Return type:
PyNode
- mgear.core.utils.filter_nurbs_curve_selection(func)
- mgear.core.utils.gatherCustomModuleDirectories(envvarkey, defaultModulePath, component=False)
returns component directory
- Parameters:
envvarkey – The environment variable key name, that is searched
defaultModulePath – The default module path for search in.
- Returns:
[]string}
- Return type:
Dict{string
- mgear.core.utils.getModuleBasePath(directories, moduleName)
search component path
- mgear.core.utils.get_dag_path(name)
Gets the dag path for the specified object name.
- Parameters:
name (str) – Name of the object in the Maya Scene.
- Returns:
The dag path to the specified name, else None.
- Return type:
OpenMaya.MDagPath
- mgear.core.utils.get_frame_rate()
Returns the current scene’s fps.
- Returns:
The fps for the current scene’s timeline.
- Return type:
int
- mgear.core.utils.get_maya_path()
Gets the path to the folder where Maya binary lives
Note: Only works from inside Maya, as Maya adds the path on startup.
- Returns:
Absolute path to the binary folder that contains maya executable
- Return type:
str
- mgear.core.utils.get_os()
Gets the OS that Maya is running in.
- Returns:
Current OS
- Return type:
str
- mgear.core.utils.importFromStandardOrCustomDirectories(directories, defaultFormatter, customFormatter, moduleName)
Return imported module
- Parameters:
directories – the directories for search in. this is got by gatherCustomModuleDirectories
defaultFormatter – this represents module structure for default module. for example “mgear.core.shifter.component.{}”
customFormatter – this represents module structure for custom module. for example “{0}.{1}”
- Returns:
imported module
- Return type:
module
- mgear.core.utils.is_odd(num)
Check if the number is odd.
Arguments: num (int): the number
- Returns:
True or False
- Return type:
bool
- mgear.core.utils.one_undo(func)
Decorator - guarantee close chunk.
type: (function) -> function
- mgear.core.utils.set_frame_rate(fps)
Set Maya Scene’s frame rate(fps).
- Parameters:
fps (int) – frames per a second for playback.
- mgear.core.utils.timeFunc(func)
Use as a property to time any desired function
- mgear.core.utils.viewport_off(func)
Decorator - Turn off Maya display while func is running.
if func will fail, the error will be raised after.
type: (function) -> function