本文整理汇总了Python中Red9.core.Red9_Meta.getConnectedMetaNodes方法的典型用法代码示例。如果您正苦于以下问题:Python Red9_Meta.getConnectedMetaNodes方法的具体用法?Python Red9_Meta.getConnectedMetaNodes怎么用?Python Red9_Meta.getConnectedMetaNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Red9.core.Red9_Meta
的用法示例。
在下文中一共展示了Red9_Meta.getConnectedMetaNodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getNodesOverload
# 需要导入模块: from Red9.core import Red9_Meta [as 别名]
# 或者: from Red9.core.Red9_Meta import getConnectedMetaNodes [as 别名]
def getNodesOverload(poseObj, nodes, *args):
# NOTE: poseObj already has an attr 'metaRig' which is filled
# automatically in the main buildInternalPoseData() call
metaNode = poseObj.metaRig
currentSelection = cmds.ls(sl=True, l=True)
filteredNodes = []
if not issubclass(type(metaNode), r9Meta.MetaHIKControlSetNode):
# see if we have a controller selected thats connected to an
# appropriate subMetaSystem
if not currentSelection:
result = cmds.confirmDialog(
title='selection hint missing',
button=['L_Fingers', 'R_Fingers', 'L_Toes', 'R_Toes', 'Cancel'],
message='We need a hint to ID which finger system to load/save the data too,\nIdeally you should select something in the correct limb system that we can use',
defaultButton='Cancel',
cancelButton='Cancel',
icon='information',
dismissString='Cancel')
if result == 'L_Fingers':
msystem = metaNode.L_ArmSystem
elif result == 'R_Fingers':
msystem = metaNode.R_ArmSystem
elif result == 'L_Toes':
msystem = metaNode.L_LegSystem
elif result == 'R_Toes':
msystem = metaNode.R_LegSystem
else:
msystem = r9Meta.getConnectedMetaNodes(cmds.ls(sl=True))[0]
# from selected node, or selected system find our finger / toe subSystem
if not msystem.systemType.lower() in ['fingers', 'toes']:
fingersystem = msystem.getChildMetaNodes(mAttrs=['systemType'])
if fingersystem:
fingersystem=fingersystem[0]
else:
fingersystem = msystem
if not fingersystem or not fingersystem.systemType.lower() in ['fingers', 'toes']:
raise IOError('no finger / toe metaSubSystems found from the selected node')
print '\nFinger : PoseOverload Handler : %s >> subSystem: %s' % (metaNode, fingersystem)
filteredNodes = fingersystem.getChildren()
# if cmds.getAttr('%s.mirrorSide' % currentSelection[0]) == 1:
# print '\nFinger : PoseOverload Handler : %s >> side: Left' % metaNode
# filteredNodes = metaNode.L_ArmSystem.L_FingerSystem.getChildren()
# elif cmds.getAttr('%s.mirrorSide' % currentSelection[0]) == 2:
# print '\nFinger : PoseOverload Handler : %s >> side: Right' % metaNode
# filteredNodes = metaNode.R_ArmSystem.R_FingerSystem.getChildren()
# modify the actual PoseData object, changing the data to be matched on index
# rather than using the standard name or metaMap matching
poseObj.metaPose = False
poseObj.matchMethod = 'mirrorIndex_ID'
poseObj.mirrorInverse = True # set the mirror inverse code to active to cope with mirror differences between Left and Right fingers
return filteredNodes
示例2: test_connectionsTo_MayaNodes_Basic
# 需要导入模块: from Red9.core import Red9_Meta [as 别名]
# 或者: from Red9.core.Red9_Meta import getConnectedMetaNodes [as 别名]
def test_connectionsTo_MayaNodes_Basic(self):
'''
Test how the code handles connections to standard MayaNodes
'''
cube1=cmds.ls(cmds.polyCube()[0],l=True)[0]
cube2=cmds.ls(cmds.polyCube()[0],l=True)[0]
cube3=cmds.ls(cmds.polyCube()[0],l=True)[0]
cube4=cmds.ls(cmds.polyCube()[0],l=True)[0]
#add singular Child
self.MClass.connectChild(cube1,'Singluar')
assert self.MClass.Singluar==[cube1]
#add multiple Children
self.MClass.connectChildren([cube2,cube3],'Multiple')
assert sorted(self.MClass.Multiple)==[cube2,cube3]
#get the MetaNode back from the cube1 connection and retest
found=r9Meta.getConnectedMetaNodes(cube1)[0]
assert isinstance(found,r9Meta.MetaClass)
assert found.mNode=='MetaClass_Test'
assert found.mClass=='MetaClass'
assert sorted(found.Multiple)==[cube2,cube3]
#connect something else to Singluar - cleanCurrent=True by default so unhook cube1
self.MClass.connectChild(cube2,'Singluar')
assert self.MClass.Singluar==[cube2]
assert not cmds.attributeQuery('MetaClassTest',node=cube1,exists=True) #cleaned up after ourselves?
self.MClass.connectChildren([cube3,cube4],'Singluar')
assert sorted(self.MClass.Singluar)==[cube2,cube3,cube4]
#setAttr has cleanCurrent and force set to true so remove all current connections to this attr
self.MClass.Singluar=cube1
assert self.MClass.Singluar==[cube1]
try:
#still thinking about this....if the attr isn't a multi then
#the __setattr__ will fail if you pass in a lots of nodes
self.MClass.Singluar=[cube1,cube2,cube3]
except:
assert True
self.MClass.Multiple=[cube1,cube4]
assert sorted(self.MClass.Multiple)==[cube1,cube4]
示例3:
# 需要导入模块: from Red9.core import Red9_Meta [as 别名]
# 或者: from Red9.core.Red9_Meta import getConnectedMetaNodes [as 别名]
'''
#Find the Jaw controller from the mRig
mRig.Facial.FACE_Jaw
#Get all controllers wired to the MetaRigNode
#NOTE this currently has no walk function so will only return direct wired controllers
#so in this example from the mRig it will not return the Facial Controllers
mRig.getRigCtrls()
#or facial controllers
mRig.Facial.getRigCtrls()
#finally to get the mRig node back from any of the Controllers
#Note that this command has source,destination args to clamp
#the direction of the search
r9Meta.getConnectedMetaNodes(cmds.ls(sl=True))[0]
'''
##############################################################################
# CONCLUSION : why is this good???
##############################################################################
So you now have a basically setup MetaRig. If you open the AnimationUI
and go to the Hierarchy Tab switch the MetaRig checkbox on, this will switch all
the back-end code to filter for the MetaNode systems. The hierarchy filters for
most of the setups still require you to select a node to act on, in case you have
multiple characters in the scene, but as long as its a member of the mRig then
hierarchy functions will all work on the mRig as root.
示例4:
# 需要导入模块: from Red9.core import Red9_Meta [as 别名]
# 或者: from Red9.core.Red9_Meta import getConnectedMetaNodes [as 别名]
'''
mClass = r9Meta.getMetaNodes()
mClass = r9Meta.getMetaNodes(dataType='mClass',mTypes='MetaRig')
#Return only MetaRig class objects. If the dataType isn't 'mClass' then we
#return the standard MayaNodes, else we return the mClass initialized to the class object
#Connect the selected Maya Nodes to the mClass node under a Multi-Message attr 'mirrorLeft'
node.connectChildren(cmds.ls(sl=True),'mirrorLeft')
node.mirrorLeft #will now return all connected nodes to the message attr
#Connect the selected Maya Node to the mClass node under a NON Multi-Message attr 'simpleChild'
#this is what most of the MRig calls use as a single connection describes a single MayaNode
node.connectChild(cmds.ls(sl=True)[0],'simpleChild')
node.simpleChild #will now return all connected nodes to the message attr
r9Meta.getConnectedMetaNodes(nodes, source=True, destination=True, dataType='mClass')
'''
MetaRigging!
===============================================================
NOTE: For more detailed examples of the MetaRig see the MetaRig_Morpheus.py
example in this folder.
This class is a wrapper of the main class aimed at managing complex
rigs and finding controllers. Simple concept, you make a blank mRig
node and just hook the controllers up to it.
'''
mRig=r9Meta.MetaRig()
mRig.addGenericCtrls(cmds.ls(sl=True)) #add all given nodes to the 'RigCtrl' msgLink
mRig.getRigCtrls() #return all RigCtrls from above