Tk-maya: Customize Auto Context Switching?

Heya,

I realize fully-supported context switching requires Step and Task folders, but we have a situation where the entire Task name is the file name suffix. I’m wondering if it’s possible to customize the auto context switching in Maya without forking the app? If not, is there a place I could implement my own context switching whenever a user opens a Maya file on disk, if the tk-maya auto context switching is disabled?

Thanks for any ideas!

Jesse

I don’t fully understand your issue. Can’t it be solved with templates?

The engine does not seem to call any hooks itself during context switching, but it does call engine.switch_context which iirc triggers the core hooks pre_context_change and post_context_change.

Sorry I wasn’t clear. We have Step but not Task folders. The issue (as I understand it) is that, if you don’t have a Task folder in your Template, the complete Context of a file cannot be determined. So what I am trying to do is take the specific Task context from the filename itself when artists open files outside of the Workfiles2 app.

I have managed to determine Task context from the Step folder + Task filename in Publisher, I’m looking to do the same thing in Maya but it looks like I might have to somehow trigger the context change manually and not use the auto context switching…

I believe you can achieve what you want in the pre_context_change (core) hook.
We had a similar case, and ended up simply adding the task to the file templates - it is the simplest and most direct solution.

Awesome, I’ll give that a try!