Python源码示例:pymel.core.setAttr()
示例1
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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)
示例16
def setKeyableAttributes(nodes,
params=["tx", "ty", "tz",
"ro", "rx", "ry", "rz",
"sx", "sy", "sz"]):
"""Set keyable attributes of a node.
By defaul will set 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 keyable.
Attrs not in the list will be locked
if None, ["tx", "ty", "tz", "rorder", "rx", "ry", "rz", "sx", "sy",
"sz"] is used
"""
localParams = ["tx", "ty", "tz",
"ro", "rx", "ry", "rz",
"sx", "sy", "sz",
"v"]
if not isinstance(nodes, list):
nodes = [nodes]
for attr_name in params:
for node in nodes:
node.setAttr(attr_name, lock=False, keyable=True)
for attr_name in localParams:
if attr_name not in params:
for node in nodes:
node.setAttr(attr_name, lock=True, keyable=False)
示例17
def setRotOrder(node, s="XYZ"):
"""Set the rotorder of the object.
Arguments:
node (dagNode): The object to set the rot order on.
s (str): Value of the rotorder.
Possible values : ("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX")
"""
a = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"]
if s not in a:
mgear.log("Invalid Rotorder : " + s, mgear.sev_error)
return False
# Unless Softimage there is no event on the rotorder parameter to
# automatically adapt the angle values
# So let's do it manually using the EulerRotation class
er = datatypes.EulerRotation([pm.getAttr(node + ".rx"),
pm.getAttr(node + ".ry"),
pm.getAttr(node + ".rz")],
unit="degrees")
er.reorderIt(s)
node.setAttr("ro", a.index(s))
node.setAttr("rotate", er.x, er.y, er.z)
示例18
def changeAttrToBoundValue(self):
# type: () -> None
pm.setAttr(self.getChangeAttrName(), self.getValue())
示例19
def changeAttrToBoundValue(self):
# type: () -> None
pm.setAttr(self.getChangeAttrName(), self.getValue())
示例20
def createMultMatrixNode(mA, mB, target=False, transform='srt'):
"""Create Maya 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("multMatrix")
for m, mi in zip([mA, mB], ['matrixIn[0]', 'matrixIn[1]']):
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 + ".matrixSum",
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
示例21
def createReverseNode(input, output=None):
"""Create and connect a reverse node.
Arguments:
input (attr or list of 3 attr): The attribute input.
output (attr or list of 3 attr): The attribute to connect the
output.
Returns:
pyNode: the newly created node.
>>> fkvis_node = nod.createReverseNode(self.blend_att)
"""
node = pm.createNode("reverse")
if not isinstance(input, list):
input = [input]
for item, s in zip(input, "XYZ"):
if (isinstance(item, str)
or isinstance(item, unicode)
or isinstance(item, pm.Attribute)):
pm.connectAttr(item, node + ".input" + s)
else:
pm.setAttr(node + ".input" + s, item)
if output:
if not isinstance(output, list):
output = [output]
for out, s in zip(output, "XYZ"):
pm.connectAttr(node + ".output" + s, out, f=True)
return node
示例22
def createAddNode(inputA, inputB):
"""Create and connect a addition node.
Arguments:
inputA (attr or float): The attribute input A
inputB (attr or float): The attribute input B
Returns:
pyNode: the newly created node.
>>> add_node = nod.createAddNode(self.roundness_att, .001)
"""
node = pm.createNode("addDoubleLinear")
if (isinstance(inputA, str)
or isinstance(inputA, unicode)
or isinstance(inputA, pm.Attribute)):
pm.connectAttr(inputA, node + ".input1")
else:
pm.setAttr(node + ".input1", inputA)
if (isinstance(inputB, str)
or isinstance(inputB, unicode)
or isinstance(inputB, pm.Attribute)):
pm.connectAttr(inputB, node + ".input2")
else:
pm.setAttr(node + ".input2", inputB)
return node
# TODO: update using plusMinusAverage node
示例23
def createSubNode(inputA, inputB):
"""Create and connect a subtraction node.
Arguments:
inputA (attr or float): The attribute input A
inputB (attr or float): The attribute input B
Returns:
pyNode: the newly created node.
>>> sub_nod = nod.createSubNode(self.roll_att, angle_outputs[i-1])
"""
node = pm.createNode("addDoubleLinear")
if (isinstance(inputA, str)
or isinstance(inputA, unicode)
or isinstance(inputA, pm.Attribute)):
pm.connectAttr(inputA, node + ".input1")
else:
pm.setAttr(node + ".input1", inputA)
if (isinstance(inputB, str)
or isinstance(inputB, unicode)
or isinstance(inputB, pm.Attribute)):
neg_node = pm.createNode("multiplyDivide")
pm.connectAttr(inputB, neg_node + ".input1X")
pm.setAttr(neg_node + ".input2X", -1)
pm.connectAttr(neg_node + ".outputX", node + ".input2")
else:
pm.setAttr(node + ".input2", -inputB)
return node
示例24
def createDivNode(inputA, inputB, output=None):
"""Create and connect a Divide node.
Arguments:
inputA (attr, float or list of float): The attribute input A
inputB (attr, float or list of float): The attribute input B
output (attr or list of attr): The attribute to connect the
output.
Returns:
pyNode: the newly created node.
Example:
.. code-block:: python
# Classic Maya style creation and connection = 4 lines
div1_node = pm.createNode("multiplyDivide")
div1_node.setAttr("operation", 2)
div1_node.setAttr("input1X", 1)
pm.connectAttr(self.rig.global_ctl+".sx",
div1_node+".input2X")
# mGear style = 1 line
div1_node = nod.createDivNode(1.0,
self.rig.global_ctl+".sx")
"""
return createMulDivNode(inputA, inputB, 2, output)
示例25
def createPlusMinusAverage1D(input, operation=1, output=None):
"""Create a multiple average node 1D.
Arguments:
input (attr, float or list): The input values.
operation (int): Node operation. 0=None, 1=sum, 2=subtract,
3=average
output (attr): The attribute to connect the result.
Returns:
pyNode: the newly created node.
"""
if not isinstance(input, list):
input = [input]
node = pm.createNode("plusMinusAverage")
node.attr("operation").set(operation)
for i, x in enumerate(input):
try:
pm.connectAttr(x, node + ".input1D[%s]" % str(i))
except RuntimeError:
pm.setAttr(node + ".input1D[%s]" % str(i), x)
if output:
pm.connectAttr(node + ".output1D", output)
return node
示例26
def createNegateNodeMulti(name, inputs=[]):
"""Create and connect multiple negate nodes
Arguments:
name (str): The name for the new node.
inputs (list of attr): The list of attributes to negate
Returns:
list: The output attributes list.
"""
s = "XYZ"
count = 0
i = 0
outputs = []
for input in inputs:
if count == 0:
real_name = name + "_" + str(i)
node_name = pm.createNode("multiplyDivide", n=real_name)
i += 1
pm.connectAttr(input, node_name + ".input1" + s[count], f=True)
pm.setAttr(node_name + ".input2" + s[count], -1)
outputs.append(node_name + ".output" + s[count])
count = (count + 1) % 3
return outputs
示例27
def createAddNodeMulti(inputs=[]):
"""Create and connect multiple add nodes
Arguments:
inputs (list of attr): The list of attributes to add
Returns:
list: The output attributes list.
>>> angle_outputs = nod.createAddNodeMulti(self.angles_att)
"""
outputs = [inputs[0]]
for i, input in enumerate(inputs[1:]):
node_name = pm.createNode("addDoubleLinear")
if (isinstance(outputs[-1], str)
or isinstance(outputs[-1], unicode)
or isinstance(outputs[-1], pm.Attribute)):
pm.connectAttr(outputs[-1], node_name + ".input1", f=True)
else:
pm.setAttr(node_name + ".input1", outputs[-1])
if (isinstance(input, str)
or isinstance(input, unicode)
or isinstance(input, pm.Attribute)):
pm.connectAttr(input, node_name + ".input2", f=True)
else:
pm.setAttr(node_name + ".input2", input)
outputs.append(node_name + ".output")
return outputs
示例28
def createMulNodeMulti(name, inputs=[]):
"""Create and connect multiple multiply nodes
Arguments:
name (str): The name for the new node.
inputs (list of attr): The list of attributes to multiply
Returns:
list: The output attributes list.
"""
outputs = [inputs[0]]
for i, input in enumerate(inputs[1:]):
real_name = name + "_" + str(i)
node_name = pm.createNode("multiplyDivide", n=real_name)
pm.setAttr(node_name + ".operation", 1)
if (isinstance(outputs[-1], str)
or isinstance(outputs[-1], unicode)
or isinstance(outputs[-1], pm.Attribute)):
pm.connectAttr(outputs[-1], node_name + ".input1X", f=True)
else:
pm.setAttr(node_name + ".input1X", outputs[-1])
if (isinstance(input, str)
or isinstance(input, unicode)
or isinstance(input, pm.Attribute)):
pm.connectAttr(input, node_name + ".input2X", f=True)
else:
pm.setAttr(node_name + ".input2X", input)
outputs.append(node_name + ".output")
return outputs
示例29
def createDivNodeMulti(name, inputs1=[], inputs2=[]):
"""Create and connect multiple divide nodes
Arguments:
name (str): The name for the new node.
inputs1 (list of attr): The list of attributes
inputs2 (list of attr): The list of attributes
Returns:
list: The output attributes list.
"""
for i, input in enumerate(pm.inputs[1:]):
real_name = name + "_" + str(i)
node_name = pm.createNode("multiplyDivide", n=real_name)
pm.setAttr(node_name + ".operation", 2)
if (isinstance(pm.outputs[-1], str)
or isinstance(pm.outputs[-1], unicode)
or isinstance(pm.outputs[-1], pm.Attribute)):
pm.connectAttr(pm.outputs[-1], node_name + ".input1X", f=True)
else:
pm.setAttr(node_name + ".input1X", pm.outputs[-1])
if (isinstance(input, str)
or isinstance(input, unicode)
or isinstance(input, pm.Attribute)):
pm.connectAttr(input, node_name + ".input2X", f=True)
else:
pm.setAttr(node_name + ".input2X", input)
pm.outputs.append(node_name + ".output")
return pm.outputs
示例30
def set_anim_curve_color(anim_curve, color):
"""sets animCurve color to color
"""
anim_curve = get_valid_node(anim_curve)
anim_curve.setAttr("useCurveColor", True)
anim_curve.setAttr("curveColor", color, type="double3")