How to get original value of attribute overridden by render setup layer?


If an attribute in maya is being overridden by a render setup layer, is there a way to get the base, non-overridden value of that attribute without switching to the default render layer? So, for example, if the start frame in the render globals is set to 0, but my current render setup layer is applying an absolute override setting it to 100, is there a way to access the original value without changing the current layer in maya?

Ultimately I want to be able to query the value of an attribute in a layer that is not the current layer (for the purposes of sending tasks to a render farm). I don’t want to change the active layer in maya as that can be slow with a lot of layers, and I want to avoid making changes to the scene if possible. I’ve been using the render setup python api to query overrides, but I’ve not yet found a way to find the original value if the currently active layer is overriding the value I’m trying to query in a different layer.

This is the code I’m using to get the value currently:

def getAttrForSetupLayer(node, attr, setupLayer):        
        import as renderSetup
        import maya.cmds as cmds
        renderSetupHandler = renderSetup.instance()

        # get the current value of the attribute
        result = cmds.getAttr("{0}.{1}".format(node, attr))

        # apply overrides
        if cmds.objExists(setupLayer) and cmds.nodeType(setupLayer) == "renderSetupLayer":
                currentLayerObject = renderSetupHandler.getRenderLayer(setupLayer)
            except Exception as err:
                log.error("could not get current layer object for {0}: {1}".format(setupLayer, err))
                currentLayerObject = None
            if currentLayerObject is not None:
                layerCollections = currentLayerObject.getCollections()
                for coll in layerCollections:
                    collectionOverrides = coll.getOverrides()
                    for override in collectionOverrides:
                        # not all override types have targetNodeName, so catch exceptions
                            targetNode = override.targetNodeName()
                            targetAttr = override.attributeName()
                        if targetNode == node and targetAttr == attr:
                            if override.typeName() == "relUniqueOverride":
                                mult = override.getMultiply()
                                offset = override.getOffset()
                                result = result*mult+offset
                                    result = override.getAttrValue()
                                except Exception as err:
                                    log.error("could not get override for {0}.{1} on layer {2}: {3}".format(node, attr, setupLayer, err))

However, this only works if there is no override on the attribute in the current layer. If the override in the current layer is a relative attribute, I can work back and get the original value, but if it’s absolute I can’t find a way to do it (and having to ‘work back’ doesn’t seem like an ideal solution anyway!)

I’m still learning the ropes of the render setup api - I hope someone can point me in the right direction!



Old topic but for what it’s worth, maybe you or anyone could give this script a try.
The purpose of this script is to query attribute in any layer from any layer without switching.