Trigger another app when creating a file with tk-multi-workfiles

Hello Shotgun Community!

We are using tk-multi-setframerange. We would like to automatically trigger it when creating a new Maya file for exemple.

From what I’ve seen so far tk-multi-workfiles2 has the following hook setting:
tk-multi-workfiles documentation

hook_scene_operation

Type: hook

Default Value: {self}/scene_operation_{engine_name}.py

Description: All the application specific scene operations (open, save etc) that the app needs to carry out are collected together in this hook.

So within this hook_scene_operation, how to properly call tk-multi-setframrange?

Cheers,
Kevin

3 Likes

So for a new scene, you would want to put your logic in the elif operation == "reset": block of the hook.
To run the app, you have two choices

Call the registered command

engine = self.parent.engine

# Optional, but just so we can see what commands are registered.
self.logger.debug(engine.commands.keys())

app_command = engine.commands.get("Sync Frame Range with Shotgun")

if app_command:
    # now run the command, which in this case will launch the Sync Frame Range app.
    app_command["callback"]()

Call the app’s public methods

engine = self.parent.engine
app = engine.apps.get("tk-multi-setframerange")
framerange = app.get_current_frame_range()
4 Likes

Wonderful Philip. Calling the registered command is exactly what I was looking for.
Thank you for your help.

Cheers,
Kevin

3 Likes