本文整理匯總了Python中pymel.core.PyNode方法的典型用法代碼示例。如果您正苦於以下問題:Python core.PyNode方法的具體用法?Python core.PyNode怎麽用?Python core.PyNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymel.core
的用法示例。
在下文中一共展示了core.PyNode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getBaseCtrl
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def getBaseCtrl(self, sCtrlType, sAttrName, sCtrlName, fRadius, iDegree = 1, iSection = 8):
nCtrl = None
self.ctrlCreated = False
try:
nCtrl= self.masterGrp.getAttr(sAttrName)
except pymel.MayaAttributeError:
try:
nCtrl = pymel.PyNode(self.prefix + sCtrlName)
except pymel.MayaNodeError:
if (sCtrlName != (self.prefix + "Option_Ctrl")):
nCtrl = pymel.PyNode(self.ctrls.cvControl(sCtrlType, sCtrlName, r=fRadius, d=iDegree, dir="+X"))
else:
nCtrl = pymel.PyNode(self.ctrls.cvCharacter(sCtrlType, sCtrlName, r=(fRadius*0.2)))
self.ctrlCreated = True
finally:
#Since there is no connection between the master and the node found, create the connection
self.masterGrp.addAttr(sAttrName, attributeType='message')
nCtrl.message.connect(self.masterGrp.attr(sAttrName))
return nCtrl
示例2: test_emptyClass
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def test_emptyClass(self):
data_inn = EmptyClass()
self._monkeypatch_various_types(data_inn)
# Serializae
network = export_network(data_inn)
self.assertTrue(isinstance(network, pymel.PyNode))
# Deserialize
data_out = import_network(network)
# Compare output
for att in dir(data_out):
if att[0] != '_':
val_inn = getattr(data_inn, att)
val_out = getattr(data_out, att)
if isinstance(val_inn, (float, long)):
pass # can't correctly raise assert (almostEqual don't work...)
else:
self.assertEquals(val_inn, val_out)
示例3: __mirror_flip_pose_callback
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def __mirror_flip_pose_callback(*args):
"""Wrapper function to call mGears mirroPose function
Args:
list: callback from menuItem
"""
# cast controls into pymel object nodes
controls = [pm.PyNode(x) for x in args[0]]
# triggers mirror
# we handle the mirror/flip each control individually even if the function
# accepts several controls. Flipping on proxy attributes like blend
# attributes cause an issue to rather than trying the complete list we do
# one control to avoid the mirror to stop
for ctl in controls:
mirrorPose(flip=args[1], nodes=[ctl])
示例4: __reset_attributes_callback
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def __reset_attributes_callback(*args):
""" Wrapper function to call mGears resetTransform function
Args:
list: callback from menuItem
"""
attribute = args[1]
for node in args[0]:
control = pm.PyNode(node)
if attribute == "translate":
resetTransform(control, t=True, r=False, s=False)
if attribute == "rotate":
resetTransform(control, t=False, r=True, s=False)
if attribute == "scale":
resetTransform(control, t=False, r=False, s=True)
示例5: getMirror
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def getMirror(node):
"""Get the mirrored node usin _L and _R replacement
Arguments:
node (dagNode or list of dagNodes): The dagNode to look for a
mirror
Returns:
dagNode or list of dagNodes: The dagNode contrapart on the other
side _L or _R
"""
if not isinstance(node, list):
node = [node]
mirrorNodes = []
for n in node:
try:
mirrorNodes.append(pm.PyNode(string.convertRLName(n.name())))
except Exception:
pm.displayInfo("The object: %s doesn't have mirror _L or _R "
"contrapart. Skipped!" % n.name())
mirrorNodes.append(n)
return mirrorNodes
示例6: connectSet
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [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: as_pynode
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def as_pynode(obj):
"""Check and convert a given string to Pynode
If the object is not str or unicode or PyNode will raise type error
Args:
obj (str, unicode, PyNode): Object to check and/or convert to PyNode
Returns:
PyNode: the pynode object
"""
if isinstance(obj, str) or isinstance(obj, unicode):
obj = pm.PyNode(obj)
if not isinstance(obj, pm.PyNode):
raise TypeError("{} is type {} not str, unicode or PyNode".format(
str(obj), type(obj)))
return obj
示例8: recordNodesMatrices
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def recordNodesMatrices(nodes, desiredTime):
"""get the matrices of the nodes provided and return a dict of
node:matrix
Args:
nodes (list): of nodes
Returns:
dict: node:node matrix
"""
nodeToMat_dict = {}
for fk in nodes:
fk = pm.PyNode(fk)
nodeToMat_dict[fk.name()] = fk.getAttr("worldMatrix", time=desiredTime)
return nodeToMat_dict
示例9: getControlers
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def getControlers(model, gSuffix=CTRL_GRP_SUFFIX):
"""Get thr controlers from the set
Args:
model (PyNode): Rig root
gSuffix (str, optional): set suffix
Returns:
list: The members of the group
"""
try:
ctl_set = pm.PyNode(model.name() + gSuffix)
members = ctl_set.members()
return members
except TypeError:
return None
示例10: toggleAttr
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def toggleAttr(model, object_name, attr_name):
"""Toggle a boolean attribute
Args:
model (PyNode): Rig top node
object_name (str): The name of the control containing the attribute to
toggle
attr_name (str): The attribute to toggle
"""
nameSpace = getNamespace(model)
if nameSpace:
node = dag.findChild(nameSpace + ":" + object_name)
else:
node = dag.findChild(model, object_name)
oAttr = node.attr(attr_name)
if oAttr.type() in ["float", "bool"]:
oVal = oAttr.get()
if oVal == 1:
oAttr.set(0)
else:
oAttr.set(1)
# ================================================
示例11: getComboKeys
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def getComboKeys(model, object_name, combo_attr):
"""Get the keys from a combo attribute
Args:
model (PyNode): Rig top node
object_name (str): Control name
combo_attr (str): Combo attribute name
Returns:
list: Keys names from the combo attribute.
"""
nameSpace = getNamespace(model)
return getComboKeys_with_namespace(nameSpace, object_name, combo_attr)
##################################################
# IK FK switch match
##################################################
# ================================================
示例12: spine_IKToFK
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def spine_IKToFK(fkControls, ikControls, matchMatrix_dict=None):
"""position the IK controls to match, as best they can, the fk controls.
Supports component: spine_S_shape_01, spine_ik_02
Args:
fkControls (list): list of fk controls, IN THE ORDER OF HIERARCHY,
["spine_C0_fk0_ctl", ..., ..., "spine_C0_fk6_ctl"]
ikControls (list): all ik controls
"""
if matchMatrix_dict is None:
currentTime = pm.currentTime(q=True)
matchMatrix_dict = recordNodesMatrices(fkControls,
desiredTime=currentTime)
attribute.reset_SRT(ikControls)
for fk in fkControls:
fk = pm.PyNode(fk)
fk.setMatrix(matchMatrix_dict[fk.name()], worldSpace=True)
示例13: gatherMirrorData
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def gatherMirrorData(nameSpace, node, flip):
"""Get the data to mirror
Args:
nameSpace (str): Namespace
node (PyNode): No
flip (TYPE): flip option
Returns:
[dict[str]: The mirror data
"""
if isSideElement(node.name()):
nameParts = stripNamespace(node.name()).split("|")[-1]
nameParts = swapSideLabel(nameParts)
nameTarget = ":".join([nameSpace, nameParts])
oTarget = getNode(nameTarget)
return calculateMirrorData(node, oTarget, flip=flip)
else:
return calculateMirrorData(node, node, flip=False)
示例14: setCtrls
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def setCtrls(self, fks, ik, upv, ikRot):
# type: (list[str], str, str) -> None
"""gather core PyNode represented each controllers"""
self.fkCtrls = [self._getNode(x) for x in fks]
self.fkTargets = [self._getMth(x) for x in fks]
self.ikCtrl = self._getNode(ik)
self.ikTarget = self._getMth(ik)
self.upvCtrl = self._getNode(upv)
self.upvTarget = self._getMth(upv)
if ikRot:
self.ikRotCtl = self._getNode(ikRot)
self.ikRotTarget = self._getMth(ikRot)
self.hasIkRot = True
else:
self.hasIkRot = False
示例15: addTransform
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import PyNode [as 別名]
def addTransform(parent, name, m=datatypes.Matrix()):
"""Create a transform dagNode.
Arguments:
parent (dagNode): The parent for the node.
name (str): The Node name.
m (matrix): The matrix for the node transformation (optional).
Returns:
dagNode: The newly created node.
"""
node = pm.PyNode(pm.createNode("transform", n=name))
node.setTransformation(m)
if parent is not None:
parent.addChild(node)
return node