diff --git a/info.yml b/info.yml index c4802f5..8623a85 100644 --- a/info.yml +++ b/info.yml @@ -48,6 +48,11 @@ configuration: type: dict tank_type: type: tank_type + tank_channel: + type: str + use_node_name: + type: bool + default_value: False render_template: type: template fields: context, version, SEQ, [channel], [output], [name], [width], [height], [eye], [YYYY], [MM], [DD], * diff --git a/python/tk_nuke_writenode/handler.py b/python/tk_nuke_writenode/handler.py index 5bd2c75..d1805fe 100644 --- a/python/tk_nuke_writenode/handler.py +++ b/python/tk_nuke_writenode/handler.py @@ -1026,6 +1026,8 @@ def __set_profile(self, node, profile_name, reset_all_settings=False): file_type = profile["file_type"] file_settings = profile["settings"] tile_color = profile["tile_color"] + use_node_name = profile["use_node_name"] + tank_channel = profile["tank_channel"] promote_write_knobs = profile.get("promote_write_knobs", []) # Make sure any invalid entries are removed from the profile list: @@ -1036,6 +1038,25 @@ def __set_profile(self, node, profile_name, reset_all_settings=False): # update both the list and the cached value for profile name: self.__update_knob_value(node, "profile_name", profile_name) self.__update_knob_value(node, "tk_profile_list", profile_name) + + # Save the old output knob values + old_use_node_name = node.knob(TankWriteNodeHandler.USE_NAME_AS_OUTPUT_KNOB_NAME).value() + old_output_name = node.knob(TankWriteNodeHandler.OUTPUT_KNOB_NAME).value() + + output_name = tank_channel + if use_node_name: + # Ensure that the output name matches the node name if + # that option is enabled on the node. This is primarily + # going to handle the situation where a node with "use name as + # output name" enabled is copied and pasted. When it is + # pasted the node will get a new name to avoid a collision + # and we need to make sure we update the output name to + # match that new name. + output_name = node.knob("name").value() + + # update the output tank channel + self.__update_knob_value(node, TankWriteNodeHandler.OUTPUT_KNOB_NAME, output_name) + self.__update_knob_value(node, TankWriteNodeHandler.USE_NAME_AS_OUTPUT_KNOB_NAME, use_node_name) # set the format self.__populate_format_settings( @@ -1125,7 +1146,9 @@ def __set_profile(self, node, profile_name, reset_all_settings=False): # Reset the render path but only if the named profile has changed - this will only # be the case if the user has changed the profile through the UI so this will avoid # the node automatically updating without the user's knowledge. - if profile_name != old_profile_name: + # Also update if the use_node_name or tank_channel attrs have changed. + if profile_name != old_profile_name or use_node_name != old_use_node_name or \ + output_name != old_output_name: self.reset_render_path(node) def __populate_initial_output_name(self, template, node):