From 077df63286bbeae3374aad8c19ee6e5e71033780 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 13 Dec 2018 08:43:18 +0100 Subject: [PATCH] Correctly perform attribute type value conversion for render layer overrides --- colorbleed/maya/lib.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index 7b5f8fab2d..dd97e46be7 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -2118,15 +2118,27 @@ def get_attr_in_layer(attr, layer): type="renderLayer") or [] connections = filter(lambda x: x.endswith(".plug"), connections) - if not connections: + if not connections or layer == cmds.editRenderLayerGlobals(query=True, + currentRenderLayer=True): return cmds.getAttr(attr) - + + # Some value types perform a conversion when assigning + # TODO: See if there's a maya method to allow this conversion + # instead of computing it ourselves. + attr_type = cmds.getAttr(attr, type=True) + conversion = None + if attr_type == "time": + conversion = mel.eval('currentTimeUnitToFPS()') # returns float + for connection in connections: - if connection.startswith(layer): + if connection.startswith(layer + "."): attr_split = connection.split(".") if attr_split[0] == layer: attr = ".".join(attr_split[0:-1]) - return cmds.getAttr("%s.value" % attr) + value = cmds.getAttr("%s.value" % attr) + if conversion: + value *= conversion + return value else: # When connections are present, but none @@ -2138,6 +2150,9 @@ def get_attr_in_layer(attr, layer): attr_split = connection.split(".") if attr_split[0] == "defaultRenderLayer": attr = ".".join(attr_split[0:-1]) - return cmds.getAttr("%s.value" % attr) + value = cmds.getAttr("%s.value" % attr) + if conversion: + value *= conversion * conversion + return value return cmds.getAttr(attr)