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


Python OpenMaya.MFnDependencyNode方法代码示例

本文整理汇总了Python中maya.api.OpenMaya.MFnDependencyNode方法的典型用法代码示例。如果您正苦于以下问题:Python OpenMaya.MFnDependencyNode方法的具体用法?Python OpenMaya.MFnDependencyNode怎么用?Python OpenMaya.MFnDependencyNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.api.OpenMaya的用法示例。


在下文中一共展示了OpenMaya.MFnDependencyNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_superclass

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def test_superclass():
    """cmdx.Node(dagmobject) creates a DagNode"""

    # Using the right class works
    mobj = om.MFnDagNode().create("transform")
    node = cmdx.DagNode(mobj)
    assert isinstance(node, cmdx.DagNode)

    mobj = om.MFnDependencyNode().create("polySplit")
    node = cmdx.Node(mobj)
    assert isinstance(node, cmdx.Node)

    # Using the wrong class works too
    mobj = om.MFnDagNode().create("transform")
    node = cmdx.Node(mobj)
    assert isinstance(node, cmdx.DagNode)

    mobj = om.MFnDependencyNode().create("polySplit")
    node = cmdx.DagNode(mobj)
    assert isinstance(node, cmdx.Node) 
开发者ID:mottosso,项目名称:cmdx,代码行数:22,代码来源:tests.py

示例2: _zoomRatio

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def _zoomRatio(self, basePoint):
        # type: (om.MPoint) -> float
        """Calculate zoom factor as distance from the current view's camera position."""
        # FIXME: all views share this value from current one.

        # camera distance
        cameraPath = omui.M3dView.active3dView().getCamera()
        camNode = om.MFnDependencyNode(cameraPath.node())
        isOrtho = camNode.findPlug("orthographic", False)

        camMat = cameraPath.inclusiveMatrix().homogenize()
        camPos = om.MPoint(
            camMat.getElement(3, 0),
            camMat.getElement(3, 1),
            camMat.getElement(3, 2),
        )

        if isOrtho.asBool():
            orthoWidth = camNode.findPlug("orthographicWidth", False).asFloat()
            return math.ldexp(orthoWidth, 3) * 0.01
        else:
            return basePoint.distanceTo(camPos) * 0.1 
开发者ID:yamahigashi,项目名称:MayaManipulatorDrawer,代码行数:24,代码来源:sceneRenderOverride.py

示例3: containerFromNode

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def containerFromNode(mayaNode):
    """

    :param mayaNode: `MObject` any dependency node in Maya
    :return: `MObject | None` the container object the argument is linked to if there is one
                                otherwise None
    """
    fnDep = om2.MFnDependencyNode(mayaNode)
    plug = fnDep.findPlug("message", False)

    for eachDestPlug in plug.destinations():
        destNode = eachDestPlug.node()
        if not destNode.hasFn(om2.MFn.kHyperLayout):
            continue

        # at this point we're dealing with an interesting node
        #  and we should find if it's connected to a container
        fnDestNode = om2.MFnDependencyNode(destNode)
        layoutMsg = fnDestNode.findPlug("message", False)

        layoutDestinations = layoutMsg.destinations()
        for eachLayoutDestination in layoutDestinations:
            if eachLayoutDestination.node().hasFn(om2.MFn.kContainer):
                return eachLayoutDestination.node() 
开发者ID:CultOfRig,项目名称:didactic,代码行数:26,代码来源:s01_d023_retrievingContainedObjects.py

示例4: containerFromNode

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def containerFromNode(mayaNode):
    """
    :param mayaNode: `MObject` any dependency node in Maya
    :return: `MObject | None` the container object the argument is linked to if there is one
                                otherwise None
    """
    fnDep = om2.MFnDependencyNode(mayaNode)
    plug = fnDep.findPlug("message", False)

    for eachDestPlug in plug.destinations():
        destNode = eachDestPlug.node()
        if not destNode.hasFn(om2.MFn.kHyperLayout):
            continue

        # at this point we're dealing with an interesting node
        #  and we should find if it's connected to a container
        fnDestNode = om2.MFnDependencyNode(destNode)
        layoutMsg = fnDestNode.findPlug("message", False)

        layoutDestinations = layoutMsg.destinations()
        for eachLayoutDestination in layoutDestinations:
            if eachLayoutDestination.node().hasFn(om2.MFn.kContainer):
                return eachLayoutDestination.node() 
开发者ID:CultOfRig,项目名称:didactic,代码行数:25,代码来源:s01_d025_swappingPlugs.py

示例5: containerFromNode

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def containerFromNode(mayaNode):
    """
    Inspects a node connection set for standard containered topology and returns
      the owning container if one is found, None otherwise
    :param mayaNode: `MObject` any dependency node in Maya
    :return: `MObject | None` the container object the argument is linked to if there is one
                                otherwise None
    """
    fnDep = om2.MFnDependencyNode(mayaNode)
    plug = fnDep.findPlug("message", False)

    for eachDestPlug in plug.destinations():
        destNode = eachDestPlug.node()
        if not destNode.hasFn(om2.MFn.kHyperLayout):
            continue

        # at this point we're dealing with an interesting node
        #  and we should find if it's connected to a container
        fnDestNode = om2.MFnDependencyNode(destNode)
        layoutMsg = fnDestNode.findPlug("message", False)

        layoutDestinations = layoutMsg.destinations()
        for eachLayoutDestination in layoutDestinations:
            if eachLayoutDestination.node().hasFn(om2.MFn.kContainer):
                return eachLayoutDestination.node() 
开发者ID:CultOfRig,项目名称:didactic,代码行数:27,代码来源:s01_d030_makeUsable.py

示例6: iterContainersFromObjectIterator

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def iterContainersFromObjectIterator(generator, suffixFilter = CONTAINER_SUFFIX):
    """
    Generator iterating connected containers given an MObject iterator and an optional filter
    The filter will also act as a trim factor to reduce the name of the object,
      this helps since the name of the component shouldn't include the suffix
      describing the object type inspected.
    :param generator: `generator` A Python Generator that yield MObject types
    :param suffixFilter: `str` A string to restrict yield to items with a certain suffix.
                               Can be None, False, or empty if filter is undesirable
    :return: `(str, MObjectHandle)` A tuple containing the name of the container and the
                                      Maya object handle of the container node
    """
    for x in generator():
        container = containerFromNode(x)
        if container is None:
            continue

        k = om2.MFnDependencyNode(container).name()
        if suffixFilter:
            if not k.endswith(suffixFilter):
                continue
            k = k[:-len(suffixFilter)]

        yield k, om2.MObjectHandle(container) 
开发者ID:CultOfRig,项目名称:didactic,代码行数:26,代码来源:s01_d030_makeUsable.py

示例7: _check_created_node

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def _check_created_node(cls):
        """
        Catches all network nodes that are meta types. If they aren't in the meta dictionary they will be added.
        Should only apply to copied meta nodes and imported meta nodes as they dont go through the normal meta node
        create function. Always runs deferred, therefore this will not reliably catch metas from a batch process.
        If this is needed look at using update_meta_dictionary from your batch (scene load/new will also run
        update_meta_dictionary).
        """
        m_obj = cls.created_m_objs.pop(0)
        m_objs_uuid = om2.MFnDependencyNode(m_obj).uuid()
        if m_objs_uuid.valid():
            uuid = m_objs_uuid.asString()
            nodes = pm.ls(uuid)
            if nodes:
                if pm.hasAttr(nodes[0], META_TYPE):
                    if nodes[0].attr(META_TYPE).get() in meta.core.Register.__meta_types__.keys():
                        metanode_class = meta.core.Register.__meta_types__[nodes[0].attr(META_TYPE).get()]
                        if all(metanode.uuid != uuid for metanode in cls.meta_dict.get(metanode_class.meta_type, [])):
                            if metanode_class.meta_type not in cls.meta_dict:
                                cls.meta_dict[metanode_class.meta_type] = []
                            new_meta = metanode_class(nodes[0])
                            cls.meta_dict[metanode_class.meta_type].append(new_meta)
                            om2.MUserEventMessage.postUserEvent(cls.create_event, (metanode_class.meta_type, new_meta))
                            new_meta.created_event() 
开发者ID:arenanet,项目名称:metanode,代码行数:26,代码来源:manager.py

示例8: _ls

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def _ls():
    """Yields Avalon container node names.

    Used by `ls()` to retrieve the nodes and then query the full container's
    data.

    Yields:
        str: Avalon container node name (objectSet)

    """

    def _maya_iterate(iterator):
        """Helper to iterate a maya iterator"""
        while not iterator.isDone():
            yield iterator.thisNode()
            iterator.next()

    ids = {AVALON_CONTAINER_ID,
           # Backwards compatibility
           "pyblish.mindbender.container"}

    # Iterate over all 'set' nodes in the scene to detect whether
    # they have the avalon container ".id" attribute.
    fn_dep = om.MFnDependencyNode()
    iterator = om.MItDependencyNodes(om.MFn.kSet)
    for mobject in _maya_iterate(iterator):
        if mobject.apiTypeStr != "kSet":
            # Only match by exact type
            continue

        fn_dep.setObject(mobject)
        if not fn_dep.hasAttribute("id"):
            continue

        plug = fn_dep.findPlug("id", True)
        value = plug.asString()
        if value in ids:
            yield fn_dep.name() 
开发者ID:getavalon,项目名称:core,代码行数:40,代码来源:pipeline.py

示例9: isPlugInteresting

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def isPlugInteresting(self, plug, targetPlug):
        mfn_dep = om.MFnDependencyNode(plug.node())
        return plug == mfn_dep.findPlug(targetPlug, True)

    # 
开发者ID:Viele,项目名称:onionSkinRenderer,代码行数:7,代码来源:onionSkinRendererCore.py

示例10: get_object_uuid

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def get_object_uuid(node):
    """Get PyNode UUID value as string."""
    sel_list = om2.MSelectionList()
    sel_list.add(node.name())
    m_obj = sel_list.getDependNode(0)
    return om2.MFnDependencyNode(m_obj).uuid().asString() 
开发者ID:arenanet,项目名称:metanode,代码行数:8,代码来源:core.py

示例11: node_deleted_callback

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def node_deleted_callback(cls, m_obj, _):
        """
        Delete events created for any Metanode that is deleted.

        :param m_obj: MObject for deleted network node.
        :param _: Extra argument passed from delete event.
        """
        uuid = om2.MFnDependencyNode(m_obj).uuid().asString()
        for key, value in cls.meta_dict.iteritems():
            for metanode in value:
                if metanode.uuid == uuid:
                    value.remove(metanode)
                    om2.MUserEventMessage.postUserEvent(cls.destroy_event, (metanode.meta_type, metanode))
                    metanode.deleted_event()
                    break 
开发者ID:arenanet,项目名称:metanode,代码行数:17,代码来源:manager.py

示例12: nodes

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def nodes(self):
        # The nodes function will filter through the nodes and make sure we only give back valid nodes
        validNodes = []

        # The selection list will help us validate whether a node exists or not
        sel = om.MSelectionList()

        # Lets iterate through the node list we've captured
        for node in self.__nodes:
            # If the node is null, it means the MObject no longer points to valid data so we can ignore it
            if node.isNull():
                continue

            # We now have to get the path of the node
            # If the node is a dagNode (checked by seeing if it has that function set)
            # Then we need to get its shortest unique path
            if node.hasFn(om.MFn.kDagNode):
                # We create an MFnDagNode for it
                dag = om.MFnDagNode(node)
                # The partial path is the shortest unique name to the object
                # A full path can be wasteful in terms of memory
                # But just the name can lead to ambiguity if multiple objects share the name
                # The partial path instead gives us the shortest name we know to be unique
                path = dag.partialPathName()
            else:
                # If it isn't a DAGNode, then it's a DG node and always has a unique name
                dg = om.MFnDependencyNode(node)
                path = dg.name()

            # Even once we have the path, it may not exist anymore (if deleted etc)
            # We'll try and add it to the selection list and if it fails to add then we'll assume it no longer exists
            try:
                sel.add(path)
            except:
                continue

            # Then add it to the validNodes list
            validNodes.append(path)

        # Finally return the node list
        return validNodes 
开发者ID:dgovil,项目名称:AdvancedPythonForMaya,代码行数:43,代码来源:createdNodesContext.py

示例13: asMObject

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def asMObject(node):
    '''
    Return API 2.0 dependency node from the given pynode or string.
    '''

    _list = OpenMaya.MSelectionList()
    if isinstance(node, basestring):
        _list.add( node )
    else:
        _list.add( node.name() )
    return OpenMaya.MFnDependencyNode( _list.getDependNode( 0 ) ) 
开发者ID:patcorwin,项目名称:fossil,代码行数:13,代码来源:capi.py

示例14: lsattrs

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def lsattrs(attrs):
    """Return nodes with the given attribute(s).

    Arguments:
        attrs (dict): Name and value pairs of expected matches

    Example:
        >> # Return nodes with an `age` of five.
        >> lsattr({"age": "five"})
        >> # Return nodes with both `age` and `color` of five and blue.
        >> lsattr({"age": "five", "color": "blue"})

    Return:
         list: matching nodes.

    """

    dep_fn = om.MFnDependencyNode()
    dag_fn = om.MFnDagNode()
    selection_list = om.MSelectionList()

    first_attr = attrs.iterkeys().next()

    try:
        selection_list.add("*.{0}".format(first_attr),
                           searchChildNamespaces=True)
    except RuntimeError as exc:
        if str(exc).endswith("Object does not exist"):
            return []

    matches = set()
    for i in range(selection_list.length()):
        node = selection_list.getDependNode(i)
        if node.hasFn(om.MFn.kDagNode):
            fn_node = dag_fn.setObject(node)
            full_path_names = [path.fullPathName()
                               for path in fn_node.getAllPaths()]
        else:
            fn_node = dep_fn.setObject(node)
            full_path_names = [fn_node.name()]

        for attr in attrs:
            try:
                plug = fn_node.findPlug(attr, True)
                if plug.asString() != attrs[attr]:
                    break
            except RuntimeError:
                break
        else:
            matches.update(full_path_names)

    return list(matches) 
开发者ID:getavalon,项目名称:core,代码行数:54,代码来源:lib.py

示例15: __init__

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnDependencyNode [as 别名]
def __init__(self, mobject, exists=True, modifier=None):
        """Initialise Node

        Private members:
            mobject (om.MObject): Wrap this MObject
            fn (om.MFnDependencyNode): The corresponding function set
            modifier (om.MDagModifier, optional): Operations are
                deferred to this modifier.
            destroyed (bool): Has this node been destroyed by Maya?
            state (dict): Optional state for performance

        """

        self._mobject = mobject
        self._fn = self._Fn(mobject)
        self._modifier = modifier
        self._destroyed = False
        self._removed = False
        self._hashCode = None
        self._state = {
            "plugs": dict(),
            "values": dict(),
            "callbacks": list()
        }

        # Callbacks
        self.onDestroyed = list()
        self.onRemoved = list()

        Stats.NodeInitCount += 1

        self._state["callbacks"] += [
            # Monitor node deletion, to prevent accidental
            # use of MObject past its lifetime which may
            # result in a fatal crash.
            om.MNodeMessage.addNodeDestroyedCallback(
                mobject,
                self._onDestroyed,  # func
                None  # clientData
            ) if not ROGUE_MODE else 0,

            om.MNodeMessage.addNodeAboutToDeleteCallback(
                mobject,
                self._onRemoved,
                None
            ),
        ] 
开发者ID:mottosso,项目名称:cmdx,代码行数:49,代码来源:cmdx.py


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