[SOLVED] Run collector and publisher hooks in Maya through script not through top menu

Hello everybody!

I have a problem I’m trying to solve.
Let’s say I have hundreds of maya files with some geometry in them. They are not connected to any project yet. I open Shotgrid app and open Maya through it. Since those files are not tied to any task I can’t use top side Menu Shotgrid–>Open File. I have to open those normally through maya menu (File–> Open Scene)

From here I’m running a script that get input from user what task/pipeline step this file should be in, and then script is publishing this file in correct place.

My question is, can I run my custom collector hooks from here and then publish them with my custom publish hooks? I want to avoid writing the logic again. I want to use already existing collectors to run through this file. Do you guys have some ideas how this should be done?

What is currently limiting you from doing that?

You can make the publisher app show in a project context by adding a reference to that app/settings under the maya.project bit in the tk-multi-publish2.yaml file.

Thank you for your reply!

I’m a junior TD, so it’s possible I’m missing something obvious.
Up untill now all my collectors where run from publish app ( in Maya: Shotgrid–>Publish).
But If I open maya files as I mentioned in my first post ( which is File–>Open scene) I don’t have access to publisher app. All I see is:
image

Which is to be expected, since this file is not tied to any project/step.

I menagaed to publish a file from a script using sgtk.util.register_publish()
So I guess I can now open file normally and run things normally. But I would like to automate that.

Just ensure that the files you open live inside a tank folder instead of completely outside of the project (i.e. on your desktop or somewhere else not related to the shotgrid install).

If you open a file Shotgrid Toolkit will try to extract the context from that file by extracting it’s path components to see if they match ShotGrid paths and records.

if your Shotgrid Tank folder is here: G:/Projects/ProjectA
but the file you open in maya is located here: G:/misc_files/myfile.mb ShotGrid can’t understand the context and all toolkit functions will be disabled.

So just move your 100 files into the project folder and open from there.

1 Like

Huh, didn’t know about that functionality ^^

I guess it can work for now!

1 Like