当前位置: 首页>>代码示例>>Python>>正文


Python OpenMaya.MFnDependencyNode方法代码示例

本文整理汇总了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 
开发者ID:wiremas,项目名称:spore,代码行数:22,代码来源:node_utils.py

示例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() 
开发者ID:wiremas,项目名称:spore,代码行数:21,代码来源:node_utils.py

示例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() 
开发者ID:blurstudio,项目名称:cross3d,代码行数:26,代码来源:mayauserprops.py

示例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
	#-------------------------------------------------------------------------------- 
开发者ID:blurstudio,项目名称:cross3d,代码行数:20,代码来源:mayascenewrapper.py

示例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()) 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:21,代码来源:instanceAlongCurve.py

示例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) 
开发者ID:wiremas,项目名称:spore,代码行数:17,代码来源:spore_command.py

示例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)) 
开发者ID:wiremas,项目名称:spore,代码行数:37,代码来源:instance_data.py

示例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)) 
开发者ID:wiremas,项目名称:spore,代码行数:32,代码来源:instance_data.py

示例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) 
开发者ID:wiremas,项目名称:spore,代码行数:7,代码来源:node_utils.py

示例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 
开发者ID:wiremas,项目名称:spore,代码行数:33,代码来源:node_utils.py

示例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) 
开发者ID:blurstudio,项目名称:cross3d,代码行数:13,代码来源:mayascenewrapper.py

示例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) 
开发者ID:blurstudio,项目名称:cross3d,代码行数:6,代码来源:mayascenewrapper.py

示例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 
开发者ID:Viele,项目名称:onionSkinRenderer,代码行数:14,代码来源:onionSkinRendererCore.py

示例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 
开发者ID:davidlatwe,项目名称:NodeSticker,代码行数:30,代码来源:sticker.py

示例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 
开发者ID:davidlatwe,项目名称:NodeSticker,代码行数:16,代码来源:sticker.py


注:本文中的maya.OpenMaya.MFnDependencyNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。