-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmds.py
68 lines (54 loc) · 1.99 KB
/
cmds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
The contents of this module can be directly accessed via the
:py:mod:`paya.runtime` interface. This includes:
* The entire :mod:`pymel.core` namespace
* :class:`~paya.lib.names.Name`
* :func:`~paya.lib.mathops.createMatrix` / ``cm``
* :class:`~paya.lib.skel.Chain`
* ``controlShapes``, an instance of :class:`~paya.lib.controlshapes.ControlShapesLibrary`
Any module-level variables or functions added here will also become available
via :py:mod:`paya.runtime`.
.. warning::
When customising this module, take care not to **shadow** factory commands from
:mod:`pymel.core`. Doing so may break code that accesses such commands via
:mod:`paya.runtime`.
"""
import re
import maya.mel as mel
from pymel.core import *
from paya.util import toOs
from paya.lib.names import Name
from paya.lib.typeman import conform
from paya.lib.mathops import createMatrix, \
createScaleMatrix, cm, csm, degToUI, info as mathInfo
from paya.lib.skel import Chain
from paya.lib.controls import createControl, \
createControls, controlShapes, getControls
from paya.partcreator import partCreator
from paya.config import config
def saveScriptEditor():
"""
Convenience wrapper for MEL's ``syncExecuterBackupFiles()``.
"""
# should deprecate soon, due to new Save All Script Editor tabs menu command
mel.eval('syncExecuterBackupFiles')
test = None
def findMelProc(procName):
"""
Convenience wrapper for MEL's `whatIs`. Returns just a path to
a MEL file. If on Windows, the path will be back-slashed for
easy copy-paste into an editor.
:param procName: the MEL proc to locate
:raises RuntimeError: not a MEL procedure
:return: the path to the MEL file, in OS format
:rtype: str
"""
cmd = 'whatIs {}'.format(procName)
result = mel.eval(cmd)
pat = r"^Mel procedure found in: (.*)$"
mt = re.match(pat, result)
if mt:
path = toOs(mt.groups()[0])
print(path)
return path
raise RuntimeError("Not a MEL procedure.")