It can be done. It's not fool proof but it'll get you working with float
values
def get_attr_in_layer(attr=None, layer=None):
"""
Same as cmds.getAttr but this gets the attribute's value in a given
render layer without having to switch to it
:param attr: string - ex: "node.attribute"
:param layer: string - ex: "layer_name"
:return: multi - can return any objects
"""
connection_list = cmds.listConnections(attr, plugs=True)
if connection_list is None:
return cmds.getAttr(attr)
for connection in connection_list:
attr_component_list = connection.split(".")
if attr_component_list[0] == layer:
attr = ".".join(attr_component_list[0:-1])
print attr
return cmds.getAttr("%s.value" % attr)
return cmds.getAttr(attr)
def set_attr_in_layer(attr=None, layer=None, value=None):
"""
Same as cmds.setAttr but this sets the attribute's value in a given
render layer without having to switch to it
:param attr: string - ex: "node.attribute"
:param layer: string - ex: "layer_name"
:param value: value you want to set the override to
:return: bool - True if successful, False if not
"""
cmds.editRenderLayerAdjustment(attr, layer=layer)
connection_list = cmds.listConnections(attr, plugs=True)
if connection_list is not None:
for connection in connection_list:
attr_component_list = connection.split(".")
if attr_component_list[0] == layer:
attr = ".".join(attr_component_list[0:-1])
cmds.setAttr("%s.value" % attr, value)
return True
return False
On Thursday, October 30, 2014 at 5:08:36 AM UTC-7, Jacob Gonzalez wrote:
>
> by the looks of it, you are right.
>
> so basically, what I'd like to achieve can't be done!
>
> Thans
>
> On Thursday, 30 October 2014 11:11:03 UTC, Fredrik Averpil wrote:
>>
>> I may be wrong here but as far as I know you need the renderlayer you
>> wish to modify to be the currently active renderlayer.
>>
>> Regards,
>> Fredrik
>>
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/ef37b831-1f7d-4520-965e-fa5b215e20f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.