SGTK apps : Add action in context menu

Hi everyone, simple question here, I wanted to know if I can add actions to the context menu (right+click) in some of the apps via hooks instead of having to modify the app package itself.

I possibly need different actions for different projects, and want to avoid a duplicate of the app packages for each project.

:slight_smile:

3 Likes

Hi Tristan –

Can you give a little more information about what you’re trying to do here? Which app are you looking to modify? What are you right-clicking on?

Thanks!

1 Like

I’m sorry, it was a bit “general”.

When we need to open a publish file with the tk-multi-workfiles2, we want to choose if we really want to open that file or a relative workfile instead.

To do that we want to add an action in the context menu to choose between both options.

And I was wondering if there’s a hook to do it or if we have to modify the app code to add an action in the context menu (right cliking menu) on a published file in tk-multi-workfiles2.

Thanks !

3 Likes

Or a way to add a button in the UI, using a hook.

We want to avoid app code modifications :wink:

1 Like

You can register the publish2 app more than once in the same environment, and give it different settings and menu name, a bit like described here:

Is that what you are after?

1 Like

Thanks Philip, it’s really interesting to learn that we can register the publish2 app more than once !

I made a mistake, I was talking about the tk-multi-workfiles2 and not the publish2… I corrected my post in consequence.

2 Likes

You can add custom actions to the context menu when you right click on a file in workfiles.
You should be able to do this by taking over the custom_actions hook. Annoyingly though we don’t appear to have any documentation on that, other than the comments in the default hook code.

And unfortunately, I don’t have the time right now to write up a detailed explanation on how to use it, but maybe that is enough to put you on the right path? If not let me know and I’ll try and find some time to write something up.

3 Likes

Thanks a lot !
I’ll have a look at this hook !!!

It’s enough on my side for now. :slight_smile:

Thanks

4 Likes

Hi everybody, I tested the custom_actions hook and that’s exactly what I need.

But, it’s a bit wired, if I change the hook in the app package, everything works fine.
But if I use an hook file from elsewhere (editing the settings to point to that file), it works when no scene is opened. But as soon as I open a scene, my custom_actions are not available anymore in the Open UI.

Test 01

  • Edit custom_actions.py in tk-multi-workfiles2
  • Launch Houdini
  • Launch the Open UI
  • Custom actions are available
  • Open a file
  • Relaunch the Open UI
  • Custom actions are still available

Test 02

  • Add edited custom_actions in tk_config/config/core/hooks/tk-multi-workfiles2
  • Edit tk-multi-workfiles2.yml setting file and make the custom_actions_hook setting to point to that file
  • Launch Houdini
  • Launch the Open UI
  • Custom actions are available
  • Open a file
  • Relaunch the Open UI
  • Custom actions are not present

Any idea ?

1 Like

Hey Tristan, without looking at the code I think I know whats at play here.
When you open a scene the context changes from “project” to “shot” or “asset” and if your app/custom actions hook is not configured in that environment it will not be loaded.

Make sure you add the hook settings to each of the environements you want the actions to appear:

env\includes\settings\tk-multi-workfiles2.yml

settings.tk-multi-workfiles2.nuke.project
settings.tk-multi-workfiles2.nuke.shot_step
settings.tk-multi-workfiles2.nuke.asset_step

etc…

Hope this helps!

5 Likes

Seems logic !

Didn’t understand the settings and the context where connected this way.

I’ll give it a try, but thanks !

3 Likes

Yeah I didn’t either at the beginning but basically each app kind of reloads when the context switches. (Or unloads if it’s not needed in that context, like the nuke writenodes)

2 Likes