本文整理汇总了Python中maya.cmds.listConnections方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.listConnections方法的具体用法?Python cmds.listConnections怎么用?Python cmds.listConnections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.listConnections方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dpLoadBSNode
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def dpLoadBSNode(self, *args):
""" Load selected object as blendShapeNode
"""
selectedList = cmds.ls(selection=True)
if selectedList:
if cmds.objectType(selectedList[0]) == "blendShape":
cmds.textField(self.bsNodeTextField, edit=True, text=selectedList[0])
self.dpLoadBSTgtList(selectedList[0])
self.bsNode = selectedList[0]
elif cmds.objectType(selectedList[0]) == "transform":
meshList = cmds.listRelatives(selectedList[0], children=True, shapes=True, noIntermediate=True, type="mesh")
if meshList:
bsNodeList = cmds.listConnections(meshList[0], type="blendShape")
if bsNodeList:
self.dpLoadBSTgtList(bsNodeList[0])
self.bsNode = bsNodeList[0]
else:
mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
else:
mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
else:
mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
else:
mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
示例2: initialize_filtering
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def initialize_filtering(self):
# texture filter
if self.use_tex:
try:
texture = cmds.listConnections('{}.emitTexture'.format(self.node_name))[0]
except RuntimeError:
texture = None
if texture:
self.evaluate_uvs()
self.texture_filter(texture, 0) # TODO - Filter size
# altitude filter
if self.min_altitude != 0 or self.max_altitude != 1:
self.altitude_filter(self.min_altitude, self.max_altitude, self.min_altitude_fuzz, self.max_altitude_fuzz)
# slope filter
if self.min_slope != 0 or self.max_slope != 180:
self.slope_filter(self.min_slope, self.max_slope, self.slope_fuzz)
示例3: get_all_tag_children
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def get_all_tag_children(node):
"""Gets all child tag controls from the given tag node
Args:
node (dagNode): Controller object with tag
Returns:
list: List of child controls (Maya transform nodes)
"""
# store child nodes
children = []
# gets first child control
child = cmds.controller(node, query=True, children=True)
# loop on child controller nodes to get all children
while child is not None:
children.extend(child)
tag = cmds.ls(cmds.listConnections(child[0], type="controller"))
if cmds.listConnections("{}.parent".format(tag[0])) == node:
return children
child = cmds.controller(tag, query=True, children=True)
return children
示例4: select_all_child_controls
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def select_all_child_controls(control, *args): # @unusedVariable
""" Selects all child controls from the given control
This function uses Maya's controller nodes and commands to find relevant
dependencies between controls
Args:
control (str): parent animation control (transform node)
*args: State of the menu item (if existing) send by mgear's dagmenu
"""
# gets controller node from the given control. Returns if none is found
tag = cmds.ls(cmds.listConnections(control), type="controller")
if not tag:
return
# query child controls
children = get_all_tag_children(tag)
# adds to current selection the children elements
cmds.select(children, add=True)
示例5: BT_ConnectSetup
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def BT_ConnectSetup(set = None):
if not set or not cmds.objExists(set):
return False
if BT_IsSetupConnected(set = set):
cmds.warning('Setup already connected!')
return False
btNode = cmds.getAttr(set +'.Blend_Node')
if not btNode or not cmds.objExists(btNode):
return False
transforms = cmds.listConnections(set +'.dagSetMembers')
for i in range(0, len(transforms)):
try:
BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i])
except:
pass
mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide')
if mults:
cmds.delete(mults)
return True
示例6: __iter__
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def __iter__(self):
mapSets = dict()
cons = cmds.listConnections(
self.name() + '.surfaceShader',
) or []
for con in cons:
maps = cmds.listConnections(
con,
plugs=True,
type='file',
) or []
for mapSpec in maps:
(name, plug) = re.split(r'[.]', mapSpec)
mapPath = os.path.normpath(cmds.getAttr(name + '.fileTextureName'))
if mapPath and MaterialPropertyMap.hasKey(plug):
mapSets[MaterialPropertyMap.valueByLabel(plug)] = mapPath
else:
mapSets[plug] = mapPath
yield ('name', self.name())
yield ('maps', mapSets)
yield ('objects', [o.name() for o in self.objects()])
示例7: connectRenderMeshes
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def connectRenderMeshes(self, renderMeshes, LOD=0):
try:
cmds.undoInfo(openChunk=True)
lodAttr = None
if LOD >=0 or LOD <=4:
lodAttr = self.node + '.rendermeshes_LOD' + str(LOD)
conns = cmds.listConnections(lodAttr, plugs=1, destination=1)
if conns:
for conn in cmds.listConnections(lodAttr, plugs=1, destination=1):
cmds.disconnectAttr(lodAttr, conn)
if lodAttr:
for mesh in renderMeshes:
msgConnect(lodAttr, mesh + '.uExport')
else:
cmds.error('connectRenderMeshes>>> please specify a LOD integer (0-4) for your meshes')
except Exception as e:
print e
finally:
cmds.undoInfo(closeChunk=True)
示例8: connectRoot
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def connectRoot(self, uNode, root, rewire=1):
try:
cmds.undoInfo(openChunk=True)
if rewire:
conns = cmds.listConnections(uNode + '.export_root', plugs=1, source=1)
if conns:
for conn in conns:
cmds.disconnectAttr(conn, uNode + '.export_root')
if not attrExists(root+'.export'):
cmds.addAttr(root, longName='export', attributeType='message')
cmds.connectAttr(root + '.export', uNode + '.export_root' )
except Exception as e:
print e
finally:
cmds.undoInfo(closeChunk=True)
示例9: __create_fk
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def __create_fk(self):
ik_switch = cmds.listConnections(
"{}.ikBlend".format(self.two_bone_ik.ik_handle), d=False, plugs=True
)[0]
for ikh in [self.ik_handle_ball, self.ik_handle_toe]:
cmds.connectAttr(ik_switch, "{}.ikBlend".format(ikh))
self.ball_fk_ctrl = cmds.createNode(
"transform", name="{}_fk_ctrl".format(self.ball_joint)
)
common.snap_to(self.ball_fk_ctrl, self.ball_joint)
common.lock_and_hide(self.ball_fk_ctrl, "sv")
cmds.parent(self.ball_fk_ctrl, self.two_bone_ik.end_fk_control)
common.freeze_to_parent_offset(self.ball_fk_ctrl)
ori = cmds.orientConstraint(self.ball_fk_ctrl, self.ball_joint)[0]
cmds.connectAttr(
"{}.ikFk".format(self.two_bone_ik.config_control),
"{}.{}W0".format(ori, self.ball_fk_ctrl),
)
示例10: _set_from_curve
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def _set_from_curve(self, transform):
"""Store the parameters from an existing curve in the CurveShape object.
:param transform: Transform
"""
shape = shortcuts.get_shape(transform)
if shape and cmds.nodeType(shape) == "nurbsCurve":
create_attr = "{}.create".format(shape)
connection = cmds.listConnections(create_attr, plugs=True, d=False)
if connection:
cmds.disconnectAttr(connection[0], create_attr)
self.transform = transform
self.cvs = cmds.getAttr("{}.cv[*]".format(shape))
self.degree = cmds.getAttr("{}.degree".format(shape))
self.form = cmds.getAttr("{}.form".format(shape))
self.knots = get_knots(shape)
if cmds.getAttr("{}.overrideEnabled".format(shape)):
if cmds.getAttr("{}.overrideRGBColors".format(shape)):
self.color = cmds.getAttr("{}.overrideColorRGB".format(shape))[0]
else:
self.color = cmds.getAttr("{}.overrideColor".format(shape))
else:
self.color = None
if connection:
cmds.connectAttr(connection[0], create_attr)
示例11: input_transform
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def input_transform(self, i):
"""Get the input transform at index
:param i: Index
:return: The transform driving the input at index i
"""
input_count = cmds.getAttr("{}.inputQuatCount".format(self.name))
if i >= input_count:
raise RuntimeError("Invalid input index")
# Traverse connections to the transform
# inputQuat <- decomposeMatrix <- transform
connection = cmds.listConnections(
"{}.inputQuat[{}]".format(self.name, i), d=False
)
if not connection or cmds.nodeType(connection[0]) != "decomposeMatrix":
return None
connection = cmds.listConnections(
"{}.inputMatrix".format(connection[0]), d=False
)
return connection[0] if connection else None
示例12: zero_weights
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def zero_weights(blendshape):
"""Disconnects all connections to blendshape target weights and zero's
out the weights.
:param blendshape: Blendshape node name
:return: Dictionary of connections dict[target] = connection
"""
connections = {}
targets = get_target_list(blendshape)
for t in targets:
plug = "{}.{}".format(blendshape, t)
connection = cmds.listConnections(plug, plugs=True, d=False)
if connection:
connections[t] = connection[0]
cmds.disconnectAttr(connection[0], plug)
cmds.setAttr(plug, 0)
return connections
示例13: pivot_driver_attr
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def pivot_driver_attr(node):
'''
Start with supporting pivots driven by remap value nodes, more support in the future as requested.
'''
#rpSrc = mc.listConnections(node+'.rotatePivot', source=True, destination=False, plugs=True)
#if rpSrc and rpSrc[0].endswith('.translate') and mc.getAttr(rpSrc[0], keyable=True):
#return rpSrc[0]
for each in ('rotatePivotX', 'rotatePivotY', 'rotatePivotZ'):
src = mc.listConnections(node+'.'+each, source=True, destination=False)
if not src:
continue
srcType = mc.nodeType(src[0])
if srcType == 'remapValue':
src = mc.listConnections(src[0]+'.inputValue', source=True, destination=False, plugs=True)
if src and mc.getAttr(src[0], keyable=True) and not mc.getAttr(src[0], lock=True):
return src[0]
return None
示例14: selected
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def selected(*args):
curves = mc.keyframe(query=True, selected=True, name=True)
if not curves:
return
try:
mc.delete(ATTR_FILTER_NAME)
except:pass
try:
mc.delete(OBJ_FILTER_NAME)
except:pass
filters = list()
for c in curves:
plug = mc.listConnections(c, plugs=True, source=False, destination=True)[0]
print plug
filters.append(mc.itemFilter(byName=plug, classification='user'))
print filters
selectedFilter = mc.itemFilter(union=filters)
#mc.delete(filters)
print selectedFilter
mc.outlinerEditor('graphEditor1OutlineEd', edit=True, attrFilter=selectedFilter)
示例15: getRootAndCOM
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listConnections [as 别名]
def getRootAndCOM(node):
'''
Given either the root or COM, return root and COM based on connections.
'''
com = None
root = None
if mc.attributeQuery(COM_ATTR, node=node, exists=True):
com = node
messageCon = mc.listConnections(com+'.'+COM_ATTR, source=True, destination=False)
if not messageCon:
raise RuntimeError('Could not determine root from COM, please select root and run again.')
root = messageCon[0]
else:
messageCon = mc.listConnections(node+'.message', source=False, destination=True, plugs=True)
if messageCon:
for each in messageCon:
eachNode, attr = each.rsplit('.',1)
if attr == COM_ATTR:
com = eachNode
root = node
break
return root, com