Post app launch logic

I’d like to run some logic after the engine has started within Maya. Specifically I am wanting to check what department the current logged in user is under and then run some logic off of that.

I’ve got a user setup.py running that will import sgtk but I am not sure how I could query the user from there as the engine hasn’t launched by that point in the startup sequence.

Something like a Post App Launch Hook would be great but to my knowledge there’s only the before app launch hook?

Any ideas appreciated!

Hello @Justin_Pedersen ,

Have you looked into this tk-core hook?

Let us know if this shows potential for your needs - cheers!

Thanks Rob, that looks like the perfect match for what I was looking for!

Can’t believe I walked right past it :man_facepalming:

2 Likes

If you are putting a lot of work into this functionality I would consider bundling it in a toolkit app so you have access to everything you need.
There are various places in the toolkit app where you can put logic depending on the state of things :slight_smile:

2 Likes

When I started out and didn’t know about engine_init, I hacked engines to have an additional hook after_load which gets triggered in a specific place when the engine has been initialized.
I still think it might be a worthwhile addition - engine_init is a core hook, global for all engines.

2 Likes

This was just toggling AnimBot on if the current user had the Animation Group assigned to them.

Anything more complicated generally gets its own app / framework :smile: Huge fan of the apps and frameworks setup of SG so I use it every chance I get!

Actually a really good point! More hooks never hurt. Had to check against engine name in engine_init and then do my imports within the function like a filthy casual.

1 Like

For plugin packs and managing various sets of plugin environments per project I would highly recommend using a Package manager like CPENV (which is integrated with Toolkit).

2 Likes