Getting session path in DCC agnostic hook

Hello,

I’m looking for a way to get the current session file path from a custom DCC agnostic hook I’ve created. Is there a way to do this with existing Shotgun hooks, e.g. somehow calling hook_scene_operations for the given engine, rather than doing a whole lot of try/except for the various DCCs I’m running my hook on.

Any ideas are most welcome, thanks!

2 Likes

Hey Viktor

I’m not sure I understand fully.

Is this a hook in the “Toolkit” sense on an app or engine?

This is the bit I’m not sure quite what your asking. The Toolkit hooks exist so that we run different logic on a different engine. Thats why the workfiles app points to a different scene operation hook based on the engine.
Are you asking can you call a hook from outside of an app directly?
Where would you be calling this method/hook from?

Hi @philip.scadding , sorry for the confusion.

Is this a hook in the “Toolkit” sense on an app or engine?

Yes, in the toolkit sense. It’s basically the “publish_file” hook that I’ve copied from tk-multi-publish2, changed some functionality and overwritten the original hook in the settings configuration.

My changes to the “publish_file” hook are DCC agnostic. As part of those changes, I need to know the current session file and the way I’m getting it at the moment is doing a whole bunch of try/excepts to attempt to import different DCC API modules (e.g. maya.cmds, hou, etc.) until I have the one I need to get the current scene path with. My question is basically if there is any way to get the current session path through the engine or through another hook that I could manually call?

If there’s another way to approach this problem that you can think of - I’d appreciate any suggestions, thanks!

1 Like

AH OK. We don’t have a standardised method for getting the scene path. Usually the hooks are not DCC agnostic, in fact that is a major reason we have hooks, so that we can boot the DCC specific code out of the main app, and plug it in depending on the environment.

That said I can understand that the majority of your publish code might be standard between DCCs.
In the publish app we handle this with hook inheritance. So you could have a standard get_scene_path() method defined but not implemented in your main publish hook, and then have a separate hook that you tack on to the inheritance chain that just implements the DCC specific implementation of that method.

Does that make sense?

Or if you find yourself needing to repeat this kind of usage elsewhere in other apps, you could create a custom framework that implements these software interaction methods.

Thanks @philip.scadding

Does that make sense?

Yeah, I get what you mean. I was just wondering if there’s anything like that in place already before I move onto writing it myself. Thanks for the suggestions and detailed response, much appreciated!

2 Likes