本文整理汇总了Python中maya.mel.meval函数的典型用法代码示例。如果您正苦于以下问题:Python meval函数的具体用法?Python meval怎么用?Python meval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了meval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupScene
def setupScene():
if rad:
m.setAttr("perspShape.farClipPlane", 1000000)
meval('source createPrefWndUI; changeLinearUnit("meter")')
# force bg gradient all the time! (maya doesnt save the prefs for it!)
meval('displayPref -displayGradient true;')
示例2: snapToPosition
def snapToPosition(sourceObj, targetObj):
'''
wrapper function for abRTSnapToPosition
snaps targetObj to sourceObj
'''
meval('abRTSnapToPosition("%(sourceObj)s", "%(targetObj)s")' % locals())
示例3: test_setitem_str
def test_setitem_str(self):
meval("global string $melGlobals_test_setitem_str1")
lang.melGlobals["melGlobals_test_setitem_str1"] = "monkey"
self.assertEqual(meval("melGlobals_test_str_getter($melGlobals_test_setitem_str1)"), "monkey")
lang.melGlobals["$melGlobals_test_setitem_str1"] = "apple"
self.assertEqual(meval("melGlobals_test_str_getter($melGlobals_test_setitem_str1)"), "apple")
示例4: movePolysFromObj
def movePolysFromObj():
"""
# 1. Select faces
# 2. Shift-select targetObj
# 3. Run
"""
selFaces = mc.ls(os=1, fl=1)[:-1]
selFacesIds = [int(faceName.split("[")[1][:-1]) for faceName in selFaces]
# target object is the last selected item
targetObj = mc.ls(os=1, fl=1)[-1]
targetObjParent = mc.listRelatives(targetObj, p=1)[0]
# delete the parentConstraint if necessary
targetObjChildren = mc.listRelatives(targetObj, c=1, type="parentConstraint")
if not targetObjChildren == None:
mc.delete(targetObjChildren)
srcObj = selFaces[0].split(".")[0]
tempObj = mc.duplicate(srcObj, n="tempObj")[0]
mc.delete(selFaces)
facesToCopy = [faceName.replace(srcObj, tempObj) for faceName in selFaces]
mc.select(facesToCopy, r=1)
meval("InvertSelection;")
mc.delete()
combinedGeo = mc.polyUnite(tempObj, targetObj, ch=0, n="combinedGeo")[0]
mc.rename(combinedGeo, targetObj)
mc.parent(targetObj, targetObjParent)
mc.polyMergeVertex(targetObj, d=0.001, ch=0)
mc.delete(tempObj)
mc.select(srcObj, r=1)
示例5: fxCombine
def fxCombine(merge=False):
targets = m.ls(sl=True, l=True)
if not targets:
return
parent = m.listRelatives(targets[0], p=True, pa=True)
try:
combineResult = m.polyUnite(targets)
except RuntimeError:
m.error('Invalid selection for combine operation.')
return
if parent:
combineResult = m.parent(combineResult[0], parent[0])
m.delete(combineResult[0], ch=True)
for t in targets:
if m.objExists(t):
m.delete(t)
finalObject = m.rename(combineResult[0], getShortName(targets[0]))
m.select(finalObject)
if merge:
meval('performPolyMerge 0')
m.polyOptions(finalObject, displayBorder=True, sizeBorder=4)
m.select(finalObject)
示例6: test_setitem_int
def test_setitem_int(self):
meval("int $melGlobals_test_setitem_int1")
lang.melGlobals["melGlobals_test_setitem_int1"] = 37
self.assertEqual(meval("melGlobals_test_int_getter($melGlobals_test_setitem_int1)"), 37)
lang.melGlobals["$melGlobals_test_setitem_int1"] = 47
self.assertEqual(meval("melGlobals_test_int_getter($melGlobals_test_setitem_int1)"), 47)
示例7: doDuplicateExtract
def doDuplicateExtract():
selection = m.ls(sl=True, l=True)
if not selection:
raise RuntimeError('Bad selection. Select some polygons.')
components = defaultdict(list)
for s in selection:
split = s.split('.')
if (len(split) != 2) or (not split[1].startswith('f[')):
raise RuntimeError('Bad selection. Only polygons allowed: {}'.format(s))
components[split[0]].append(split[1])
originalObjects = components.keys()
newObjects = []
wholeDuplicatedObjects = []
for obj in originalObjects:
dup = m.duplicate(obj)[0]
newObjects.append(dup)
newSelection = [dup + '.' + c for c in components[obj]]
m.select(newSelection, r=True)
meval('InvertSelection')
if m.ls(sl=True):
m.delete()
else:
wholeDuplicatedObjects.append(obj)
m.select(selection, r=True)
return newObjects, wholeDuplicatedObjects
示例8: createIKCtrlsOnJnts
def createIKCtrlsOnJnts(ikCrv, parentCtrl, size=1):
ikCVNum = ll.getCurveCVCount(ikCrv)
prev=parentCtrl
for i in range(1, ikCVNum):
clus = mc.cluster('%s.cv[%d]'%(ikCrv, i), n=parentCtrl.replace('masterctrl','ikClus%d')%i)
cvPos = mc.xform('%s.cv[%d]'%(ikCrv, i), q=1, ws=1, t=1)
mc.select(parentCtrl)
meval('wireShape("plus")')
ikCtrl = mc.rename(masterCtrl.replace('masterctrl','ikCtrl%d'%i))
mc.xform(ikCtrl, t=cvPos, ws=1)
mc.scale(size, size, size, ikCtrl, ocp=1)
mc.makeIdentity(ikCtrl, a=1, s=1)
mc.parent(ikCtrl, parentCtrl)
lsZeroOut(ikCtrl)
ctrlPR = lsZeroOut(ikCtrl, 'PR')
mc.addAttr(ikCtrl, ln='SPACE', at='bool', k=1)
mc.setAttr(ikCtrl+'.SPACE', l=1)
mc.addAttr(ikCtrl, ln='parent', at='float', dv=0, min=0, max=1, k=1)
mc.addAttr(ikCtrl, ln='master', at='float', dv=1, min=0, max=1, k=1)
mc.addAttr(ikCtrl, ln='world', at='float', dv=0, min=0, max=1, k=1)
mc.parentConstraint(ikCtrl, clus)
cons = mc.parentConstraint(prev, parentCtrl, ctrlPR, mo=1)[0]
wal = mc.parentConstraint(cons, q=1, wal=1)
if len(wal) > 1:
mc.connectAttr(ikCtrl+'.parent', '%s.%s'%(cons, wal[0]), f=1)
mc.connectAttr(ikCtrl+'.master', '%s.%s'%(cons, wal[1]), f=1)
prev=ikCtrl
示例9: makeIKStretchy
def makeIKStretchy(aJnts, aIkJnts, aFkJnts, ikCtrl, statCtrl, stretchTarget, grp, limbName):
'''
'''
aJnts = formatStrArray(aJnts)
aIkJnts = formatStrArray(aIkJnts)
aFkJnts = formatStrArray(aFkJnts)
meval('abRTMakeIKStretchy(%(aJnts)s, %(aIkJnts)s, %(aFkJnts)s, "%(ikCtrl)s", "%(statCtrl)s", "%(stretchTarget)s", "%(grp)s", "%(limbName)s")' % locals())
示例10: test_setitem_int
def test_setitem_int(self):
meval('int $melGlobals_test_setitem_int1')
lang.melGlobals['melGlobals_test_setitem_int1'] = 37
self.assertEqual(meval('melGlobals_test_int_getter($melGlobals_test_setitem_int1)'),
37)
lang.melGlobals['$melGlobals_test_setitem_int1'] = 47
self.assertEqual(meval('melGlobals_test_int_getter($melGlobals_test_setitem_int1)'),
47)
示例11: test_setitem_str
def test_setitem_str(self):
meval('global string $melGlobals_test_setitem_str1')
lang.melGlobals['melGlobals_test_setitem_str1'] = 'monkey'
self.assertEqual(meval('melGlobals_test_str_getter($melGlobals_test_setitem_str1)'),
'monkey')
lang.melGlobals['$melGlobals_test_setitem_str1'] = 'apple'
self.assertEqual(meval('melGlobals_test_str_getter($melGlobals_test_setitem_str1)'),
'apple')
示例12: set_project
def set_project( shot, task = False):
path = '{0}{1}/{2}/{3}'.format( '/jobs/tr/users/', os.getlogin(), shot[:-5], shot)
if not task:
path += '/trackwork/scenes/maya'
else:
path += '/animwork/maya'
meval('setProject "{0}"'.format( path))
示例13: run
def run(deleteOriginals=True):
newObjects, wholeDuplicatedObjects = doDuplicateExtract()
if deleteOriginals:
m.delete()
if wholeDuplicatedObjects:
m.delete(wholeDuplicatedObjects)
meval('changeSelectMode -object')
m.select(newObjects, r=True)
示例14: test_get_dict
def test_get_dict(self):
self.assertEqual(lang.melGlobals.get_dict('melGlobals_test_get_dict'),
None)
self.assertEqual(lang.melGlobals.get_dict('melGlobals_test_get_dict',
'foo'),
'foo')
meval('global int $melGlobals_test_get_dict = 3')
self.assertEqual(lang.melGlobals.get_dict('melGlobals_test_get_dict'),
3)
self.assertEqual(lang.melGlobals.get_dict('melGlobals_test_get_dict',
'foo'),
3)
示例15: massCopySkinWeightsGo
def massCopySkinWeightsGo():
'''
select all destGeos,
shift-select srcGeo,
run
'''
sel = mc.ls(os=True)
destGeos = sel[:-1]
srcGeo = sel[-1]
srcSkn = meval('findRelatedSkinCluster %s' % srcGeo)
for geo in destGeos:
destSkn = meval('findRelatedSkinCluster %s' % geo)
mc.copySkinWeights(ss=srcSkn, ds=destSkn, ia='oneToOne', sa='closestPoint', nm=1)