本文整理匯總了Python中maya.OpenMaya.MFnDependencyNode方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenMaya.MFnDependencyNode方法的具體用法?Python OpenMaya.MFnDependencyNode怎麽用?Python OpenMaya.MFnDependencyNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.OpenMaya
的用法示例。
在下文中一共展示了OpenMaya.MFnDependencyNode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_dynamic_attributes
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def get_dynamic_attributes(mObject):
""" return all dynamic attributes of a node """
result = []
mFnDep = om.MFnDependencyNode()
objFn = om.MFnDependencyNode(mObject)
refObj = mFnDep.create(objFn.typeName())
refFn = om.MFnDependencyNode(refObj)
if (objFn.attributeCount() > refFn.attributeCount()):
for i in range(refFn.attributeCount(), objFn.attributeCount()):
attr = objFn.attribute(i)
attrFn = om.MFnAttribute(attr)
result.append(attrFn.name())
mDagMod = om.MDagModifier()
mDagMod.deleteNode(refObj)
return result
示例2: connect_to_instancer
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def connect_to_instancer(transform_node, spore_node):
""" connect a transform's matrix attribute to a instancer node
that is connected to the given spore node """
# get instancer's inputHierarchy plug
instancer_node = get_instancer(spore_node, False)
dg_fn = om.MFnDependencyNode(instancer_node)
in_plug = dg_fn.findPlug('inputHierarchy')
# get transform's matrix plug
transform_node = get_mobject_from_name(transform_node)
dag_fn = om.MFnDagNode(transform_node)
matrix_plug = dag_fn.findPlug('matrix')
# get first free plug and connect
plug_id = in_plug.numElements() + 1
dag_mod = om.MDagModifier()
dag_mod.connect(matrix_plug, in_plug.elementByLogicalIndex(plug_id))
dag_mod.doIt()
示例3: keys
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def keys(self):
# TODO MIKE: I had to do a try except here for the the object called "|groundPlane_transform".
# It's apparently always in the scene and error with that line.
try:
keys = cmds.listAttr(cross3d.SceneWrapper._mObjName(self._nativePointer), userDefined=True)
if keys:
return keys
except ValueError:
pass
return []
# http://forums.cgsociety.org/showthread.php?t=888612
# Note: I was unable to find a way to identify userDefined keys in the following method
# so I used the maya.cmds method. If possible this finish this method and replace the
# above code.
#depNode = om.MFnDependencyNode(mObj)
#total = depNode.attributeCount()
#count = 0
#while count < total:
# attr = depNode.attribute(count)
# plug = om.MPlug(mObj, attr)
# count += 1
# print count, attr.apiTypeStr(), plug.name()
示例4: _mObjName
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def _mObjName(cls, nativeObject, fullName=True):
""" A Maya Helper that returns the name of a object, because OpenMaya can't
expose the name in a single call.
:param nativeObject: The OpenMaya.MObject to get the name of
:param fullName: If True return the Name(Full Path), else return the displayName. Defaults to True
:return: nativeObject's name as a string
"""
with ExceptionRouter():
if cls._isDagNode(nativeObject):
dagPath = om.MDagPath.getAPathTo(nativeObject)
if fullName:
return dagPath.fullPathName()
return dagPath.partialPathName().split("|")[-1]
return om.MFnDependencyNode(nativeObject).name()
#--------------------------------------------------------------------------------
# cross3d private methods
#--------------------------------------------------------------------------------
示例5: attrChangeCallback
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def attrChangeCallback(self, msg, plug, otherPlug, clientData):
incomingDirection = (OpenMaya.MNodeMessage.kIncomingDirection & msg) == OpenMaya.MNodeMessage.kIncomingDirection
attributeSet = (OpenMaya.MNodeMessage.kAttributeSet & msg) == OpenMaya.MNodeMessage.kAttributeSet
isCorrectAttribute = (plug.attribute() == instanceAlongCurveLocator.instanceCountAttr)
isCorrectAttribute = isCorrectAttribute or (plug.attribute() == instanceAlongCurveLocator.instancingModeAttr)
isCorrectAttribute = isCorrectAttribute or (plug.attribute() == instanceAlongCurveLocator.instanceLengthAttr)
isCorrectAttribute = isCorrectAttribute or (plug.attribute() == instanceAlongCurveLocator.maxInstancesByLengthAttr)
isCorrectAttribute = isCorrectAttribute or (plug.attribute() == instanceAlongCurveLocator.curveStartAttr)
isCorrectAttribute = isCorrectAttribute or (plug.attribute() == instanceAlongCurveLocator.curveEndAttr)
isCorrectNode = OpenMaya.MFnDependencyNode(plug.node()).typeName() == kPluginNodeName
try:
if isCorrectNode and isCorrectAttribute and attributeSet and incomingDirection:
self.updateInstanceConnections()
except:
sys.stderr.write('Failed trying to update instances. stack trace: \n')
sys.stderr.write(traceback.format_exc())
示例6: redoIt
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def redoIt(self):
""" redo """
self.dag_mod_transform.doIt()
self.dag_mod_spore.doIt()
self.dag_mod_instancer.doIt()
# get result
result = []
dg_fn = om.MFnDependencyNode(self.spore)
result.append(dg_fn.name())
dag_fn = om.MFnDagNode(self.instancer)
result.append(dag_fn.fullPathName())
self.clearResult()
self.setResult(result)
示例7: __init__
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def __init__(self, node):
log_lvl = sys._global_spore_dispatcher.spore_globals['LOG_LEVEL']
self.logger = logging_util.SporeLogger(__name__, log_lvl)
dg_fn = om.MFnDependencyNode(node)
self.node_name = dg_fn.name()
self.node = node # TODO - hold on to selection list instead of mobj
# self.bounding_box = None
self.state = None
self.data_plug = om.MPlug()
self.data_object = om.MObject()
# instance data attributes
self.position = om.MVectorArray()
self.scale = om.MVectorArray()
self.rotation = om.MVectorArray()
self.instance_id = om.MIntArray()
self.visibility = om.MIntArray()
self.normal = om.MVectorArray()
self.tangent = om.MVectorArray()
self.u_coord = om.MDoubleArray()
self.v_coord = om.MDoubleArray()
self.poly_id = om.MIntArray()
self.color = om.MVectorArray()
self.unique_id = om.MIntArray()
self.exclusive_paint = []
# collect points for kd tree
self.np_position = np.empty((0,3), float)
self.tree = None
self.logger.info('Instanciate new InstanceData object for: {}'.format(self.node_name))
示例8: initialize_data
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def initialize_data(self):
""" get cache data from the sporeNode's instanceData plug/
:param instance_data_plug MPlug: instanceData plug """
node_fn = om.MFnDependencyNode(self.node)
self.data_plug = node_fn.findPlug('instanceData')
self.data_object = self.data_plug.asMObject()
array_attr_fn = om.MFnArrayAttrsData(self.data_object)
self.position = array_attr_fn.vectorArray('position')
self.scale = array_attr_fn.vectorArray('scale')
self.rotation = array_attr_fn.vectorArray('rotation')
self.instance_id = array_attr_fn.intArray('objectIndex')
self.visibility = array_attr_fn.intArray('visibility')
self.normal = array_attr_fn.vectorArray('normal')
self.tangent = array_attr_fn.vectorArray('tangent')
self.u_coord = array_attr_fn.doubleArray('u_coord')
self.v_coord = array_attr_fn.doubleArray('v_coord')
self.poly_id = array_attr_fn.intArray('poly_id')
self.color = array_attr_fn.vectorArray('color')
self.unique_id = array_attr_fn.intArray('unique_id')
# TODO - set bb
# get position as numpy array
for i in xrange(self.position.length()):
position = [[self.position[i].x, self.position[i].y, self.position[i].z]]
self.np_position = np.append(self.np_position, position, axis=0)
self.logger.debug('Initialize InstanceData object for: {}'.format(self.node_name))
示例9: get_dgfn_from_dagpath
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def get_dgfn_from_dagpath(dagpath):
""" return the functionset for the given dagpath """
m_object = get_mobject_from_name(dagpath)
return om.MFnDependencyNode(m_object)
示例10: get_instanced_geo
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def get_instanced_geo(spore_node):
""" return a list of dag pathes of geometry transformes that
are connected to the spore node's instancer
@param spore_node str: the name of the spore node
@return: list of string or None if no instancer is connected """
node_fn = get_dgfn_from_dagpath(spore_node)
instance_plug = node_fn.findPlug('instanceData')
plugs = om.MPlugArray()
instancer_plugs = om.MPlugArray()
instance_geo = []
if not instance_plug.isNull():
if instance_plug.connectedTo(plugs, False, True):
node = plugs[0].node()
node_fn = om.MFnDagNode(node)
inst_geo_plug = node_fn.findPlug('inputHierarchy')
if not inst_geo_plug.isNull():
for i in xrange(inst_geo_plug.numConnectedElements()):
input_plug = inst_geo_plug.elementByPhysicalIndex(i)
if input_plug.connectedTo(instancer_plugs, True, True):
geo_plug = instancer_plugs[0]
geo_node = geo_plug.node()
instance_geo.append(om.MFnDagNode(geo_node).fullPathName())
dg_node_fn = om.MFnDependencyNode(node)
instancer_node = dg_node_fn.name()
return instance_geo
示例11: _getPlug
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def _getPlug(cls, mObj, name):
""" For a given OpenMaya.MObject return the OpenMaya.MPlug object with that attribute name.
If the property does not exist, raises "RuntimeError: (kInvalidParameter): Cannot find item of required type"
:param mObj: The source MObject
:param name: The name of the attribute to get from mObj.
:return: A OpenMaya.MPlug object
"""
with ExceptionRouter():
depNode = om.MFnDependencyNode(mObj)
attr = depNode.attribute(name)
return om.MPlug(mObj, attr)
示例12: _hasAttribute
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def _hasAttribute(cls, mObj, name):
with ExceptionRouter():
depNode = om.MFnDependencyNode(mObj)
return depNode.hasAttribute(name)
示例13: isPlugInteresting
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def isPlugInteresting(self, plug, targetPlug):
mfn_dep = oldOm.MFnDependencyNode(plug.node())
return plug == mfn_dep.findPlug(targetPlug, True)
# ----------------
# INTERFACE FUNCTIONS
# add a frame to display relative to current time slider position
示例14: reveal
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def reveal():
"""Reveal custom icon from previous saved scene
Can use with scene open callback for auto display custom icon saved
from previous session.
"""
sel_list = oldOm.MSelectionList()
ns_list = [""] + oldOm.MNamespace.getNamespaces(":", True)
for ns in ns_list:
if ns in (":UI", ":shared"):
continue
try:
sel_list.add(ns + ":*." + ICON_ATTRIBUTE)
except RuntimeError:
pass
for i in range(sel_list.length()):
mobj = oldOm.MObject()
sel_list.getDependNode(i, mobj)
node = oldOm.MFnDependencyNode(mobj)
plug = node.findPlug(ICON_ATTRIBUTE)
icon_path = plug.asString()
try:
node.setIcon(os.path.expandvars(icon_path))
except RuntimeError:
pass
示例15: _parse_nodes
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnDependencyNode [as 別名]
def _parse_nodes(target):
"""Internal function for getting MFnDependencyNode"""
mfn_nodes = list()
sel_list = oldOm.MSelectionList()
for path in target:
sel_list.add(path)
for i in range(len(target)):
mobj = oldOm.MObject()
sel_list.getDependNode(i, mobj)
mfn_nodes.append(oldOm.MFnDependencyNode(mobj))
return mfn_nodes