本文整理匯總了Python中pymel.core.connectAttr方法的典型用法代碼示例。如果您正苦於以下問題:Python core.connectAttr方法的具體用法?Python core.connectAttr怎麽用?Python core.connectAttr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymel.core
的用法示例。
在下文中一共展示了core.connectAttr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _duplicate_shape
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def _duplicate_shape(old_shape):
new_shape = pymel.createNode('nurbsCurve')
# Transfert various attributes
mel_dst = '{0}.create'.format(new_shape) # prevent annoying pymel warning
pymel.connectAttr(old_shape.local, mel_dst)
new_shape.create.evaluate() # Force maya to cache the shape before unconnecting
pymel.disconnectAttr(old_shape.local, mel_dst)
# Transfert various attributes
for att_name in transferable_shape_attrs:
att_old = old_shape.attr(att_name)
att_new = new_shape.attr(att_name)
att_new.set(att_old.get())
return new_shape
示例2: source_nodes
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def source_nodes():
cmds.file(new=True, force=True)
source1, _ = pm.polyCube(name="source1")
source2, _ = pm.polyCube(name="source2")
target, _ = pm.polyCube(name="target")
ch1 = att.addAttribute(source1,
"chanName",
"double",
0,
minValue=0,
maxValue=1)
ch2 = att.addAttribute(source2,
"chanName",
"double",
0,
minValue=0,
maxValue=1)
pm.connectAttr(ch1, source1.ty)
pm.connectAttr(ch2, source2.ty)
示例3: gear_intmatrix_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def gear_intmatrix_op(mA, mB, blend=0):
"""
create mGear interpolate Matrix node.
Arguments:
mA (matrix): Input matrix A.
mB (matrix): Input matrix A.
blend (float or connection): Blending value.
Returns:
pyNode: Newly created mGear_intMatrix node
"""
node = pm.createNode("mgear_intMatrix")
pm.connectAttr(mA, node + ".matrixA")
pm.connectAttr(mB, node + ".matrixB")
if (isinstance(blend, str)
or isinstance(blend, unicode)
or isinstance(blend, pm.Attribute)):
pm.connectAttr(blend, node + ".blend")
else:
pm.setAttr(node + ".blend", blend)
return node
示例4: gear_curvecns_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def gear_curvecns_op(crv, inputs=[]):
"""
create mGear curvecns node.
Arguments:
crv (nurbsCurve): Nurbs curve.
inputs (List of dagNodes): Input object to drive the curve. Should be
same number as crv points.
Also the order should be the same as the points
Returns:
pyNode: The curvecns node.
"""
pm.select(crv)
node = pm.deformer(type="mgear_curveCns")[0]
for i, item in enumerate(inputs):
pm.connectAttr(item + ".worldMatrix", node + ".inputs[%s]" % i)
return node
示例5: gear_inverseRotorder_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def gear_inverseRotorder_op(out_obj, in_obj):
"""
Apply a sn_inverseRotorder_op operator
Arguments:
out_obj (dagNode): Output object.
in_obj (dagNode): Input object.
Returns:
pyNode: The newly created operator.
"""
node = pm.createNode("mgear_inverseRotOrder")
pm.connectAttr(in_obj + ".ro", node + ".ro")
pm.connectAttr(node + ".output", out_obj + ".ro")
return node
示例6: connectSet
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def connectSet(source, target, testInstance):
"""Connect or set attributes
Connects or set attributes depending if is instance of a instance check
Args:
source (str or Attr): Striname of the attribute or PyNode attribute
target (str or Attr): Striname of the attribute or PyNode attribute
testInstance (tuple): Tuple of types to check
"""
if not isinstance(testInstance, tuple):
testInstance = tuple(testInstance)
if isinstance(source, testInstance):
pm.connectAttr(source, target)
else:
pm.setAttr(target, source)
示例7: createDecomposeMatrixNode
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def createDecomposeMatrixNode(m):
"""
Create and connect a decomposeMatrix node.
Arguments:
m(str or attr): The matrix attribute name.
Returns:
pyNode: the newly created node.
>>> dm_node = nod.createDecomposeMatrixNode(mulmat_node+".output")
"""
node = pm.createNode("decomposeMatrix")
pm.connectAttr(m, node + ".inputMatrix")
return node
示例8: createCurveInfoNode
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def createCurveInfoNode(crv):
"""Create and connect a curveInfo node.
Arguments:
crv (dagNode): The curve.
Returns:
pyNode: the newly created node.
>>> crv_node = nod.createCurveInfoNode(self.slv_crv)
"""
node = pm.createNode("curveInfo")
shape = pm.listRelatives(crv, shapes=True)[0]
pm.connectAttr(shape + ".local", node + ".inputCurve")
return node
# TODO: update using plusMinusAverage node
示例9: createVertexPositionNode
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def createVertexPositionNode(inShape,
vId=0,
output=None,
name="mgear_vertexPosition"):
"""Creates a mgear_vertexPosition node"""
node = pm.createNode("mgear_vertexPosition", n=name)
inShape.worldMesh.connect(node.inputShape)
node.vertex.set(vId)
if output:
pm.connectAttr(output.parentInverseMatrix,
node.drivenParentInverseMatrix)
pm.connectAttr(node.output, output.translate)
return node
#############################################
# CREATE MULTI NODES
#############################################
示例10: controller_tag_connect
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def controller_tag_connect(ctt, tagParent):
"""Summary
Args:
ctt (TYPE): Teh control tag
tagParent (TYPE): The object with the parent control tag
"""
if pm.controller(tagParent, q=True):
tpTagNode = pm.PyNode(pm.controller(tagParent, q=True)[0])
tpTagNode.cycleWalkSibling.set(True)
pm.connectAttr(tpTagNode.prepopulate, ctt.prepopulate, f=True)
ni = attribute.get_next_available_index(tpTagNode.children)
pm.disconnectAttr(ctt.parent)
pm.connectAttr(ctt.parent, tpTagNode.attr(
"children[%s]" % str(ni)))
示例11: _save_settings
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def _save_settings(self):
"""save settings inside objects pivotData attribute
"""
# data to be save :
# -----------------
# futurePivot node
# create attributes
self._create_data_attribute()
# connect futurePivot node
pm.connectAttr(
'%s%s' % (self._futurePivot.name(), ".message"),
self._object.attr("pivotData.futurePivot"),
f=True
)
示例12: make_stretchy
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def make_stretchy(self):
#check joints
"""
"""
self._scaleMD = pm.createNode("multiplyDivide",
n=self.limbName + "_scaleMD")
pm.connectAttr(self.curve.curveInfo.arcLength, self.scaleMD.input1X)
pm.setAttr(self.scaleMD.input2X, self.curve.arclen)
pm.setAttr(self.scaleMD.operation, 2)
for jnt in self.joints.jointChain:
factor = pm.createNode("multiplyDivide", n="factor_" + jnt)
pm.connectAttr(self.scaleMD.outputX, factor.input1X)
pm.setAttr(factor.input2X, (pm.getAttr(jnt.ty)))
pm.connectAttr(factor.outputX, jnt.ty)
示例13: _buildBaseCtrls
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def _buildBaseCtrls(self):
# create global ctrl
self.globalCtrl = mayautils.createCtrl("{0}_all_ctrl".format(self.prefix), "crossArrow", 1, "yellow")
globalCtrlAttr = [
{"ln":"globalScale", "at":"float", "dv":1, "k":1},
{"ln":self.RIG_TOP_TAG, "dt":"string"}
]
mayautils.addAttributes(self.globalCtrl, globalCtrlAttr)
# create meta ctrl
self.metaCtrl = mayautils.createCtrl("{0}_meta_ctrl".format(self.prefix), "fatCross", 1, "yellow", None, [0,0,90])
pm.xform(self.metaCtrl, t=self.metaPos, ws=1)
mayautils.aimObject(self.endPos, self.metaCtrl)
mayautils.createParentTransform("org", self.metaCtrl).setParent(self.globalCtrl)
# build globalScale connections
for ch in 'xyz':
pm.connectAttr(self.globalCtrl.globalScale, "{0}.s{1}".format(self.metaCtrl.name(), ch))
pm.setAttr("{0}.s{1}".format(self.metaCtrl.name(), ch), cb=0, keyable=0, lock=1)
pm.setAttr("{0}.s{1}".format(self.globalCtrl.name(), ch), cb=0, keyable=0, lock=1)
示例14: on_action_axisChange
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def on_action_axisChange(self, iRow, iCol, *args):
pCell = self.ui.tblData.item(iRow,iCol)
pData = pCell.data(QtCore.Qt.UserRole)
pData.nChildLoc.axis.set(args[0])
#Delete old connection
pymel.disconnectAttr(pData.nMD.input1X)
lstXCon = pData.nDecM.outputRotateX.listConnections()
pymel.disconnectAttr(pData.nDecM.outputRotateX)
pymel.delete(lstXCon)
lstYCon = pData.nDecM.outputRotateY.listConnections()
pymel.disconnectAttr(pData.nDecM.outputRotateY)
pymel.delete(lstYCon)
lstZCon = pData.nDecM.outputRotateZ.listConnections()
pymel.disconnectAttr(pData.nDecM.outputRotateZ)
pymel.delete(lstZCon)
if args[0] == 0:
pymel.connectAttr(pData.nDecM.outputRotateX, pData.nMD.input1X, f=True)
elif args[0] == 1:
pymel.connectAttr(pData.nDecM.outputRotateY, pData.nMD.input1X, f=True)
elif args[0] == 2:
pymel.connectAttr(pData.nDecM.outputRotateZ, pData.nMD.input1X, f=True)
#Change the axis connection of the system to connect in the good axis
示例15: curvecns_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import connectAttr [as 別名]
def curvecns_op(crv, inputs=[]):
for i, item in enumerate(inputs):
node = pm.createNode("decomposeMatrix")
pm.connectAttr(item + ".worldMatrix[0]", node + ".inputMatrix")
pm.connectAttr(node + ".outputTranslate",
crv + ".controlPoints[%s]" % i)
return node