예제 #1
0
def registerDefaultTranslator(nodeType, default):
    """
    Register the default translator for a node type. The second argument identifies the name of the
    translator.  Pass the translator name (as a string) if the default is always the same,
    or a function that takes the current node as a pymel PyNode and returns the translator name as a string.

    The default will automatically be set whenever a node of the given type is added to the scene.
    """

    global _defaultTranslators
    _defaultTranslators[nodeType] = default

    isFunc = callable(default)
    if not isFunc:
        cmds.arnoldPlugins(setDefaultTranslator=(nodeType, default))
    if arnoldIsCurrentRenderer():
        it = pm.api.MItDependencyNodes()
        while not it.isDone():
            obj = it.item()
            if not obj.isNull():
                mfn = pm.api.MFnDependencyNode(obj)
                if mfn.typeName() == nodeType:
                    plug = mfn.findPlug("aiTranslator")
                    if not plug.isNull() and plug.asString() == "":
                        if isFunc:
                            val = default(obj)
                        else:
                            val = default
                        plug.setString(val)
            it.next()

    callbacks.addNodeAddedCallback(_doSetDefaultTranslator,
                                   nodeType,
                                   applyToExisting=False,
                                   apiArgs=True)
예제 #2
0
파일: core.py 프로젝트: Quazo/breakingpoint
def registerDefaultTranslator(nodeType, default):
    """
    Register the default translator for a node type. The second argument identifies the name of the
    translator.  Pass the translator name (as a string) if the default is always the same,
    or a function that takes the current node as a pymel PyNode and returns the translator name as a string.

    The default will automatically be set whenever a node of the given type is added to the scene.
    """

    global _defaultTranslators
    _defaultTranslators[nodeType] = default

    isFunc = callable(default)
    if not isFunc:
      cmds.arnoldPlugins(setDefaultTranslator=(nodeType, default))    
    if arnoldIsCurrentRenderer():
        it = pm.api.MItDependencyNodes()
        while not it.isDone():
            obj = it.item()
            if not obj.isNull():
                mfn = pm.api.MFnDependencyNode(obj)
                if mfn.typeName() == nodeType:
                    plug = mfn.findPlug("aiTranslator")
                    if not plug.isNull() and plug.asString() == "":
                        if isFunc:
                            val = default(obj)
                        else:
                            val = default
                        plug.setString(val)
            it.next()

    callbacks.addNodeAddedCallback(_doSetDefaultTranslator, nodeType,
                                   applyToExisting=False, apiArgs=True)
예제 #3
0
파일: aovs.py 프로젝트: Quazo/breakingpoint
def installCallbacks():
    _sgAliasesCallbacks = callbacks.SceneLoadCallbackQueue()
    _sgAliasesCallbacks.addCallback(createAliases, passArgs=True)
    callbacks.addNodeAddedCallback(_sgAliasesCallbacks, 'shadingEngine',
                                   applyToExisting=True, apiArgs=False)
    
    if not pm.about(batch=True):
        callbacks.addAttributeChangedCallback(_aovOptionsChangedCallbacks, 'aiOptions', 'aovList',
                                  context=pm.api.MNodeMessage.kConnectionMade | pm.api.MNodeMessage.kConnectionBroken,
                                  applyToExisting=True)
예제 #4
0
def installCallbacks():
    _sgAliasesCallbacks = callbacks.SceneLoadCallbackQueue()
    _sgAliasesCallbacks.addCallback(createAliases, passArgs=True)
    callbacks.addNodeAddedCallback(_sgAliasesCallbacks,
                                   'shadingEngine',
                                   applyToExisting=True,
                                   apiArgs=False)

    if not pm.about(batch=True):
        callbacks.addAttributeChangedCallback(
            _aovOptionsChangedCallbacks,
            'aiOptions',
            'aovList',
            context=pm.api.MNodeMessage.kConnectionMade
            | pm.api.MNodeMessage.kConnectionBroken,
            applyToExisting=True)
예제 #5
0
    def __init__(self):
        if self.window is None:
            self.window = 'MtoALightManager'
            self.listElements = []
            self.column = ''
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'directionalLight',
                                           applyToExisting=False)
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'pointLight',
                                           applyToExisting=False)
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'spotLight',
                                           applyToExisting=False)
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'areaLight',
                                           applyToExisting=False)
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'aiAreaLight',
                                           applyToExisting=False)
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'aiSkyDomeLight',
                                           applyToExisting=False)
            callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI),
                                           'aiPhotometricLight',
                                           applyToExisting=False)
            callbacks.addAttributeChangedCallback(self.meshTranslatorChanged,
                                                  'mesh',
                                                  'aiTranslator',
                                                  applyToExisting=True)

            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'directionalLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'pointLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'spotLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'areaLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'aiAreaLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'aiSkyDomeLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteLight,
                                             'aiPhotometricLight',
                                             applyToExisting=False)
            callbacks.addNodeRemovedCallback(self.deleteMeshLight,
                                             'mesh',
                                             applyToExisting=False)

            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'directionalLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'pointLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'spotLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'areaLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'aiAreaLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'aiSkyDomeLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'aiPhotometricLight',
                                             applyToExisting=True)
            callbacks.addNameChangedCallback(callbacks.Callback(
                self.refreshUI),
                                             'mesh',
                                             applyToExisting=True)
예제 #6
0
 def __init__(self):
     if self.window is None:
         self.window = 'MtoALightManager'
         self.listElements = []
         self.column = ''
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'directionalLight', applyToExisting=False)
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'pointLight', applyToExisting=False)
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'spotLight', applyToExisting=False)
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'areaLight', applyToExisting=False)
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'aiAreaLight', applyToExisting=False)
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'aiSkyDomeLight', applyToExisting=False)
         callbacks.addNodeAddedCallback(callbacks.Callback(self.refreshUI), 'aiPhotometricLight', applyToExisting=False)
         callbacks.addAttributeChangedCallback(self.meshTranslatorChanged, 'mesh', 'aiTranslator', applyToExisting=True)
         
         callbacks.addNodeRemovedCallback(self.deleteLight, 'directionalLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteLight, 'pointLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteLight, 'spotLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteLight, 'areaLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteLight, 'aiAreaLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteLight, 'aiSkyDomeLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteLight, 'aiPhotometricLight', applyToExisting=False)
         callbacks.addNodeRemovedCallback(self.deleteMeshLight, 'mesh', applyToExisting=False)
         
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'directionalLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'pointLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'spotLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'areaLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'aiAreaLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'aiSkyDomeLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'aiPhotometricLight', applyToExisting=True)
         callbacks.addNameChangedCallback(callbacks.Callback(self.refreshUI), 'mesh', applyToExisting=True)