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!
Have you looked into this
This file has been truncated.
# Copyright (c) 2018 Shotgun Software Inc.
# CONFIDENTIAL AND PROPRIETARY
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
Hook that gets executed every time an engine has been fully initialized.
from tank import Hook
def execute(self, engine, **kwargs):
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
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
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.
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
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.
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).