Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions client/ayon_nuke/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,25 @@ def get_view_process_node():
return duplicate_node(ipn_node)


def on_create_root():
if script_name():
log.info("Not a new Script. Skipping setup.")
return

log.info("New Script. Setting up ...")
Comment thread
splidje marked this conversation as resolved.
Outdated

workfile_settings = WorkfileSettings()

# Set context settings.
workfile_settings.set_context_settings()

# adding favorites to file browser
workfile_settings.set_favorites()

# template builder callbacks
start_workfile_template_builder()
Comment thread
splidje marked this conversation as resolved.
Outdated


def on_script_load():
''' Callback for ffmpeg support
'''
Expand Down
17 changes: 5 additions & 12 deletions client/ayon_nuke/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
check_inventory_versions,
set_avalon_knob_data,
read_avalon_data,
on_create_root,
on_script_load,
dirmap_file_name_filter,
add_scripts_menu,
Expand Down Expand Up @@ -162,17 +163,8 @@ def add_nuke_callbacks(project_settings: dict = None):
project_settings = get_current_project_settings()

nuke_settings = project_settings["nuke"]
workfile_settings = WorkfileSettings()

# Set context settings.
nuke.addOnCreate(
workfile_settings.set_context_settings, nodeClass="Root")

# adding favorites to file browser
nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root")

# template builder callbacks
nuke.addOnCreate(start_workfile_template_builder, nodeClass="Root")
nuke.addOnCreate(on_create_root, nodeClass="Root")

# fix ffmpeg settings on script
nuke.addOnScriptLoad(on_script_load)
Expand All @@ -181,8 +173,9 @@ def add_nuke_callbacks(project_settings: dict = None):
nuke.addOnScriptLoad(check_inventory_versions)
nuke.addOnScriptSave(check_inventory_versions)

# set apply all workfile settings on script load and save
nuke.addOnScriptLoad(WorkfileSettings().set_context_settings)
if nuke_settings["general"]["set_context_settings_on_script_open"]:
# set apply all workfile settings on script load and save

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this comment above it was just wrong?

Suggested change
# set apply all workfile settings on script load and save
# set apply all workfile settings on script load

nuke.addOnScriptLoad(WorkfileSettings().set_context_settings)

@BigRoy BigRoy Feb 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this is actually wrong - and apparently always has been?

Because this initializes WorkfileSettings DIRECTLY here - and not on the callback. As such, this is set to the context of AYON when Nuke is launched. If you open a workfile in a different context, it'd still be applying the workfile settings of the context you launched into.

Suggested change
nuke.addOnScriptLoad(WorkfileSettings().set_context_settings)
nuke.addOnScriptLoad(lambda: WorkfileSettings().set_context_settings)


if nuke_settings["dirmap"]["enabled"]:
log.info("Added Nuke's dir-mapping callback ...")
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_nuke/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ def _connect_to_above_nodes(self, node, product_name, message):
self._shift_to_previous_node_and_temp(product_name, node, message)


def convert_to_valid_instaces():
Comment thread
BigRoy marked this conversation as resolved.
def convert_to_valid_instances():
""" Check and convert to latest publisher instances

Also save as new minor version of workfile.
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_nuke/plugins/create/convert_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
get_avalon_knob_data,
NODE_TAB_NAME,
)
from ayon_nuke.api.plugin import convert_to_valid_instaces
from ayon_nuke.api.plugin import convert_to_valid_instances

import nuke

Expand Down Expand Up @@ -50,6 +50,6 @@ def find_instances(self):

def convert(self):
# loop all instances and convert them
convert_to_valid_instaces()
convert_to_valid_instances()
# remove legacy item if all is fine
self.remove_convertor_item()
2 changes: 2 additions & 0 deletions server/settings/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class MenuShortcut(BaseSettingsModel):
class GeneralSettings(BaseSettingsModel):
"""Nuke general project settings."""

set_context_settings_on_script_open: bool = SettingsField(True, title="Set Context Settings on Script Open")

menu: MenuShortcut = SettingsField(
default_factory=MenuShortcut,
title="Menu Shortcuts",
Expand Down