Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add ability to set 'tank_channel' and 'use_node_name' in environment file #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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], *
Expand Down
25 changes: 24 additions & 1 deletion python/tk_nuke_writenode/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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):
Expand Down