Hi Mois –
First just a sanity check: I’m guessing it’s a transcription error, and your actual code is correct, but you’ve got:
if operation == "prepare_new":
engine.apps["tk-setframerange"].run()
Beyond that, we’re still trying to make sense of the exact order of things, and why things would behave differently from engine to engine, but I ran this by @Ehsan on the engineering team this morning, and he had a great idea for a workaround that might suit your needs.
The idea here is that you’d use the context_change
core hook to run setframerange, but it would rely on the presence of a marker of saved state, which you’d set in the prepare_new
block in the scene_operation
hook.
That way, although the logic would be in the context_change
hook, it would only run in cases where the context was changed at New File
time.
Here’s the code, again, with big thanks to @Ehsan. Note the caveat below:
In scene_operation_tk-nuke.py
:
elif operation == "prepare_new":
context.sgtk.set_cache_item("FILE_CREATION_IN_PROGRESS", True)
In context_change.py
:
from sgtk.platform import current_engine
engine = current_engine()
if engine.name == "tk-nuke":
if current_context.sgtk.get_cache_item("FILE_CREATION_IN_PROGRESS"):
engine.apps["tk-multi-setframerange"].run_app()
current_context.sgtk.set_cache_item("FILE_CREATION_IN_PROGRESS", None)
So it IS possible, but the set_cache_item
method has this warning in its docstring:
Internal Use Only - We provide no guarantees that this method
will be backwards compatible.
Hope that helps! Let us know how it goes.