コード例 #1
0
ファイル: sceneObservable.py プロジェクト: SouthAngel/vimSet
    def _afterCreateReferenceAndRecordEditsCB(self, referenceNode,
                                              resolvedRefPath, clientData):
        # Contrary to API documentation, creation of a non-deferred
        # reference does NOT send reference loaded notifications.  Fake it
        # here: the plain after create reference notification bizarrely
        # doesn't have the reference node and resolved path arguments, so
        # use the "record edits" version.
        refPath = resolvedRefPath.expandedFullName()
        refFn = OpenMaya.MFnReference(referenceNode)
        refName = refFn.name()
        if refFn.isLoaded():
            # Awkwardly, we generate the before reference loaded message
            # AFTER the reference is actually loaded.  This is because we
            # are compensating for the fact that the Maya core does not
            # generate these messages, and must use the after create
            # reference support to do so.  The before create reference
            # message does not provide the reference node or reference
            # path, since they haven't been created yet.
            self._notifyObservers(
                eventType=SceneObservable.BEFORE_REFERENCE_LOAD,
                referenceNode=refName,
                resolvedRefPath=refPath)
            self._notifyObservers(eventType=SceneObservable.REFERENCE_LOADED,
                                  referenceNode=refName,
                                  resolvedRefPath=refPath)

        self._notifyObservers(eventType=SceneObservable.REFERENCE_CREATED,
                              referenceNode=refName,
                              resolvedRefPath=refPath)
コード例 #2
0
ファイル: scene.py プロジェクト: kthulhu/zoocore_maya
def iterReferences():
    """Generator function that returns a Mobject for each valid referene node.

    :return: Generator function with each element representing the reference node
    :rtype: Generator(om2.MObject)
    """
    iterator = om2.MItDependencyNodes(om2.MFn.kReference)

    while not iterator.isDone():
        try:
            fn = om2.MFnReference(iterator.thisNode())
            try:
                if not fn.isLoaded() or fn.isLocked():
                    continue
            except RuntimeError:
                continue
            yield fn.object()
        finally:
            iterator.next()
コード例 #3
0
ファイル: sceneObservable.py プロジェクト: SouthAngel/vimSet
    def _beforeRemoveReferenceCB(self, referenceNode, resolvedRefPath,
                                 clientData):
        refPath = resolvedRefPath.expandedFullName()
        refFn = OpenMaya.MFnReference(referenceNode)
        refName = refFn.name()
        self._notifyObservers(
            eventType=SceneObservable.BEFORE_REFERENCE_REMOVE,
            referenceNode=refName,
            resolvedRefPath=refPath)

        # If reference was loaded, send an unload notification as well.
        # Maya does not do this.
        if refFn.isLoaded():
            self._notifyObservers(
                eventType=SceneObservable.BEFORE_REFERENCE_UNLOAD,
                referenceNode=refName,
                resolvedRefPath=refPath)

            # Capture name, path of reference to pass it to the after
            # remove reference callback.
            self._refInfo = (refName, refPath)
コード例 #4
0
    def _afterOpenCB(self, clientData):
        """If file references were loaded during file open in a visible render
        layer, refresh that layer."""

        # Render layer membership is stored as a connection from the member
        # node to the legacy render layer node.  Similarly, applied
        # overrides are connected to the attribute they override.  For
        # scenes without file references, these connections persist in the
        # saved file.
        #
        # For scenes with file references, these connections are NOT saved
        # with the file: as per the file referencing architecture, they are
        # supposed to be connection reference edits stored with the file.
        #
        # However, render setup blocks all reference edits during render
        # setup operations, as the information they contain is largely
        # redundant with the render setup procedures themselves (e.g. render
        # layer membership, applied overrides).  Therefore, re-apply the
        # layer if loaded file references are present in the scene.

        layer = self.getVisibleRenderLayer()
        # Are we in a layer that isn't the default?
        if layer != self._defaultRenderLayer:
            # Are there any file reference nodes in our scene?
            refNodeNames = cmds.ls(type='reference')
            if refNodeNames:
                # Are there any loaded file reference nodes in our scene?
                refNodes = (commonUtils.nameToNode(r) for r in refNodeNames)
                loadedRef = next(
                    (r
                     for r in refNodes if OpenMaya.MFnReference(r).isLoaded()),
                    None)
                if loadedRef:
                    # backward comp after refactoring overrideManager, see overrideManager.py for details
                    if layer._backwardCompID is not None:
                        layer._transferAttributes()
                    # Unapply / reapply overrides.
                    layer.needsApplyUpdate = True
                    self.switchToLayer(layer)
コード例 #5
0
ファイル: sceneObservable.py プロジェクト: SouthAngel/vimSet
 def _afterUnloadReferenceCB(self, referenceNode, resolvedRefPath,
                             clientData):
     self._notifyObservers(
         eventType=SceneObservable.REFERENCE_UNLOADED,
         referenceNode=OpenMaya.MFnReference(referenceNode).name(),
         resolvedRefPath=resolvedRefPath.expandedFullName())
コード例 #6
0
ファイル: sceneObservable.py プロジェクト: SouthAngel/vimSet
 def _beforeLoadReferenceCB(self, referenceNode, resolvedRefPath,
                            clientData):
     self._notifyObservers(
         eventType=SceneObservable.BEFORE_REFERENCE_LOAD,
         referenceNode=OpenMaya.MFnReference(referenceNode).name(),
         resolvedRefPath=resolvedRefPath.expandedFullName())