本文整理匯總了Python中pymel.core.setAttr方法的典型用法代碼示例。如果您正苦於以下問題:Python core.setAttr方法的具體用法?Python core.setAttr怎麽用?Python core.setAttr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymel.core
的用法示例。
在下文中一共展示了core.setAttr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: gear_intmatrix_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [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
示例2: getFCurveValues
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def getFCurveValues(fcv_node, division, factor=1):
"""Get X values evenly spaced on the FCurve.
Arguments:
fcv_node (pyNode or str): The FCurve to evaluate.
division (int): The number of division you want to evaluate on
the FCurve.
factor (float): Multiplication factor. Default = 1. (optional)
Returns:
list of float: The values in a list float.
>>> self.st_value = fcu.getFCurveValues(self.settings["st_profile"],
self.divisions)
"""
incr = 1 / (division - 1.0)
values = []
for i in range(division):
pm.setAttr(fcv_node + ".input", i * incr)
values.append(pm.getAttr(fcv_node + ".output") * factor)
return values
示例3: setNotKeyableAttributes
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def setNotKeyableAttributes(nodes,
attributes=["tx", "ty", "tz",
"ro", "rx", "ry", "rz",
"sx", "sy", "sz",
"v"]):
"""Set not keyable attributes of a node.
By defaul will set not keyable the rotation, scale and translation.
Arguments:
node(dagNode): The node with the attributes to set keyable.
attributes (list of str): The list of the attributes to set not keyable
"""
if not isinstance(nodes, list):
nodes = [nodes]
for attr_name in attributes:
for node in nodes:
node.setAttr(attr_name, lock=False, keyable=False, cb=True)
示例4: setInvertMirror
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def setInvertMirror(node, invList=None):
"""Set invert mirror pose values
Arguments:
node (dagNode): The object to set invert mirror Values
"""
aDic = {"tx": "invTx",
"ty": "invTy",
"tz": "invTz",
"rx": "invRx",
"ry": "invRy",
"rz": "invRz",
"sx": "invSx",
"sy": "invSy",
"sz": "invSz"}
for axis in invList:
if axis not in aDic:
mgear.log("Invalid Invert Axis : " + axis, mgear.sev_error)
return False
node.setAttr(aDic[axis], True)
示例5: check_sequence_name
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def check_sequence_name(self):
"""checks sequence name and asks the user to set one if maya is in UI
mode and there is no sequence name set
"""
sequencer = pm.ls(type='sequencer')[0]
sequence_name = sequencer.getAttr('sequence_name')
if sequence_name == '' and not pm.general.about(batch=1) \
and not self.batch_mode:
result = pm.promptDialog(
title='Please enter a Sequence Name',
message='Sequence Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel'
)
if result == 'OK':
sequencer.setAttr(
'sequence_name',
pm.promptDialog(query=True, text=True)
)
示例6: set_zero_joint
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def set_zero_joint(self):
#Removes Zero Joint from Joint Chain
pm.joint(self.jointChain[0], e=True, zso=True, oj='xyz', sao='xup')
self.zeroJoint = self.jointChain[0]
self._zeroPos = pm.dt.Point(pm.getAttr(self._zeroJoint.translate))
self.jointChain.remove(self.jointChain[0])
self.jointPos.remove(self.jointPos[0])
pm.joint(self.jointChain[1], e=True, zso=True, oj='xyz', sao='yup')
for i in range(1, len(self.jointChain)):
pm.joint(self.jointChain[i], e=True, zso=True, oj='xyz', sao='yup')
#sets Start End Num Of Joints again
self._numOfJoints = len(self._jointChain)
#Orient Zero Joint
temporalGroup = DrawNode(Shape.transform, 'temporalGroup')
pm.parent(self.startJoint, temporalGroup.drawnNode)
print(pm.getAttr(self.zeroJoint.jointOrient))
pm.setAttr(self.zeroJoint.jointOrientX, 0)
pm.parent(self.startJoint, self.zeroJoint)
temporalGroup.delete()
示例7: _buildBaseCtrls
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [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)
示例8: _processAttr
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def _processAttr(plug, dups, forceKeys, staticValues, start, end):
'''
Used by `save`
'''
crvs = cmds.listConnections( plug, type='animCurve' )
if not crvs:
if forceKeys:
setKeyframe( plug, t=start )
setKeyframe( plug, t=end )
crvs = cmds.listConnections( plug, type='animCurve' )
else:
if not cmds.getAttr(plug, lock=True) and not cmds.listConnections(plug, s=True, d=False):
staticValues[plug] = cmds.getAttr(plug)
if crvs:
dup = cmds.duplicate(crvs)[0]
if not objExists(dup + '.' + TAGGING_ATTR):
cmds.addAttr( dup, ln=TAGGING_ATTR, dt='string' )
cmds.setAttr( dup + '.' + TAGGING_ATTR, plug, type='string' )
dups.append( dup )
示例9: pathCns
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def pathCns(obj, curve, cnsType=False, u=0, tangent=False):
"""
Apply a path constraint or curve constraint.
Arguments:
obj (dagNode): Constrained object.
curve (Nurbscurve): Constraining Curve.
cnsType (int): 0 for Path Constraint, 1 for Curve
Constraint (Parametric).
u (float): Position of the object on the curve (from 0 to 100 for path
constraint, from 0 to 1 for Curve cns).
tangent (bool): Keep tangent orientation option.
Returns:
pyNode: The newly created constraint.
"""
node = pm.PyNode(pm.createNode("motionPath"))
node.setAttr("uValue", u)
node.setAttr("fractionMode", not cnsType)
node.setAttr("follow", tangent)
pm.connectAttr(curve.attr("worldSpace"), node.attr("geometryPath"))
pm.connectAttr(node.attr("allCoordinates"), obj.attr("translate"))
pm.connectAttr(node.attr("rotate"), obj.attr("rotate"))
pm.connectAttr(node.attr("rotateOrder"), obj.attr("rotateOrder"))
pm.connectAttr(node.attr("message"), obj.attr("specifiedManipLocation"))
return node
# TODO: review function to make wupObject optional
示例10: gear_spring_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def gear_spring_op(in_obj, goal=False):
"""Apply mGear spring node.
Arguments:
in_obj (dagNode): Constrained object.
goal (dagNode): By default is False.
Returns:
pyNode: Newly created node
"""
if not goal:
goal = in_obj
node = pm.createNode("mgear_springNode")
pm.connectAttr("time1.outTime", node + ".time")
dm_node = pm.createNode("decomposeMatrix")
pm.connectAttr(goal + ".parentMatrix", dm_node + ".inputMatrix")
pm.connectAttr(dm_node + ".outputTranslate", node + ".goal")
cm_node = pm.createNode("composeMatrix")
pm.connectAttr(node + ".output", cm_node + ".inputTranslate")
mm_node = pm.createNode("mgear_mulMatrix")
pm.connectAttr(cm_node + ".outputMatrix", mm_node + ".matrixA")
pm.connectAttr(in_obj + ".parentInverseMatrix", mm_node + ".matrixB")
dm_node2 = pm.createNode("decomposeMatrix")
pm.connectAttr(mm_node + ".output", dm_node2 + ".inputMatrix")
pm.connectAttr(dm_node2 + ".outputTranslate", in_obj + ".translate")
pm.setAttr(node + ".stiffness", 0.5)
pm.setAttr(node + ".damping", 0.5)
return node
示例11: gear_mulmatrix_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def gear_mulmatrix_op(mA, mB, target=False, transform='srt'):
"""Create mGear multiply Matrix node.
Note:
This node have same functionality as the default Maya matrix
multiplication.
Arguments:
mA (matrix): input matrix A.
mB (matrix): input matrix B.
target (dagNode): object target to apply the transformation
transform (str): if target is True. out transform to SRT valid
value s r t
Returns:
pyNode: Newly created mGear_multMatrix node
"""
node = pm.createNode("mgear_mulMatrix")
for m, mi in zip([mA, mB], ['matrixA', 'matrixB']):
if isinstance(m, datatypes.Matrix):
pm.setAttr(node.attr(mi), m)
else:
pm.connectAttr(m, node.attr(mi))
if target:
dm_node = pm.createNode("decomposeMatrix")
pm.connectAttr(node + ".output", dm_node + ".inputMatrix")
if 't' in transform:
pm.connectAttr(dm_node + ".outputTranslate",
target.attr("translate"), f=True)
if 'r' in transform:
pm.connectAttr(dm_node + ".outputRotate",
target.attr("rotate"), f=True)
if 's' in transform:
pm.connectAttr(dm_node + ".outputScale",
target.attr("scale"), f=True)
return node
示例12: gear_spinePointAtOp
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def gear_spinePointAtOp(cns, startobj, endobj, blend=.5, axis="-Z"):
"""
Apply a SpinePointAt operator
Arguments:
cns (Constraint): The constraint to apply the operator on (must be a
curve, path or direction constraint).
startobj (dagNode): Start Reference.
endobj (dagNode): End Reference.
blend (float): Blend influence value from 0 to 1.
axis (string): Axis direction.
Returns:
pyNode: The newly created operator.
"""
node = pm.createNode("mgear_spinePointAt")
# Inputs
pm.setAttr(node + ".blend", blend)
pm.setAttr(node + ".axe", ["X", "Y", "Z", "-X", "-Y", "-Z"].index(axis))
pm.connectAttr(startobj + ".rotate", node + ".rotA")
pm.connectAttr(endobj + ".rotate", node + ".rotB")
# Outputs
pm.setAttr(cns + ".worldUpType", 3)
pm.connectAttr(node + ".pointAt", cns + ".worldUpVector")
return node
示例13: gear_spinePointAtOpWM
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def gear_spinePointAtOpWM(cns, startobj, endobj, blend=.5, axis="-Z"):
"""
Apply a SpinePointAt operator using world matrix
Arguments:
cns Constraint: The constraint to apply the operator on (must be a
curve, path or direction constraint).
startobj (dagNode): Start Reference.
endobj (dagNode): End Reference.
blend (float): Blend influence value from 0 to 1.
axis (str): Axis direction.
Returns:
pyNode: The newly created operator.
"""
node = pm.createNode("mgear_spinePointAt")
# Inputs
pm.setAttr(node + ".blend", blend)
pm.setAttr(node + ".axe", ["X", "Y", "Z", "-X", "-Y", "-Z"].index(axis))
dem_node1 = pm.createNode("decomposeMatrix")
dem_node2 = pm.createNode("decomposeMatrix")
pm.connectAttr(startobj + ".worldMatrix", dem_node1 + ".inputMatrix")
pm.connectAttr(endobj + ".worldMatrix", dem_node2 + ".inputMatrix")
pm.connectAttr(dem_node1 + ".outputRotate", node + ".rotA")
pm.connectAttr(dem_node2 + ".outputRotate", node + ".rotB")
# Outputs
pm.setAttr(cns + ".worldUpType", 3)
pm.connectAttr(node + ".pointAt", cns + ".worldUpVector")
return node
示例14: gear_rollsplinekine_op
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def gear_rollsplinekine_op(out, controlers=[], u=.5, subdiv=10):
"""Apply a sn_rollsplinekine_op operator
Arguments:
out (dagNode): onstrained Object.
controlers (list of dagNodes): Objects that will act as controler of
the bezier curve. Objects must have a parent that will be used as
an input for the operator.
u (float): Position of the object on the bezier curve (from 0 to 1).
subdiv (int): spline subdivision precision.
Returns:
pyNode: The newly created operator.
"""
node = pm.createNode("mgear_rollSplineKine")
# Inputs
pm.setAttr(node + ".u", u)
pm.setAttr(node + ".subdiv", subdiv)
dm_node = pm.createNode("decomposeMatrix")
pm.connectAttr(node + ".output", dm_node + ".inputMatrix")
pm.connectAttr(dm_node + ".outputTranslate", out + ".translate")
pm.connectAttr(dm_node + ".outputRotate", out + ".rotate")
# connectAttr(dm_node+".outputScale", out+".scale")
pm.connectAttr(out + ".parentMatrix", node + ".outputParent")
for i, obj in enumerate(controlers):
pm.connectAttr(obj + ".parentMatrix", node + ".ctlParent[%s]" % i)
pm.connectAttr(obj + ".worldMatrix", node + ".inputs[%s]" % i)
pm.connectAttr(obj + ".rx", node + ".inputsRoll[%s]" % i)
return node
示例15: _lockUnlockAttribute
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import setAttr [as 別名]
def _lockUnlockAttribute(node, attributes, lock, keyable):
"""Lock or unlock attributes of a node.
Arguments:
node(dagNode): The node with the attributes to lock/unlock.
attributes (list of str): The list of the attributes to lock/unlock.
"""
if not isinstance(attributes, list):
attributes = [attributes]
for attr_name in attributes:
node.setAttr(attr_name, lock=lock, keyable=keyable)