Pick_environment based on published file type

Is it possible to return a different environment from the pick_environment hooks based on PublishedFileType when loading something from workfiles or loader?

We have maya files and a custom file format that are both linked to the same task. I need to run a different environment for publishes of our custom filetype to change settings in other apps.

2 Likes

I think this would be tricky
It is possible to have a context and thus an environment based on a PublishedFile, but usually when you open a PublishedFile via workfiles you are actually switching to the context of the entity you selected in the workfiles tree. So the PublishedFile is not passed through to the pick_environment.py hook.

The other things to consider is, if you open a work file then you have no PublishedFileType as there is no PublishedFile entity (but perhaps you don’t use work files?). Also the Loader app is used to for importing stuff primarily, so does not modify the current engine context by default.

I could potentially think of a way you might be able to drive the pick_environment.py hook though.

In the workfiles2 scene operations hook, you could perhaps store an environment variable holding the file type, when performing an open or save operation. I would perhaps go off the file extension so as to handle both work files and publishes. Then in your pick_environment.py you could check for this env var grab the contents. You might also want to clear it at this point as well, I’m not sure.

Similarly if your loader actions are setup to open something, then you could modify the action to set the same env var and initiate an engine context change.

1 Like

The place I care about this is in a custom engine and the custom file is supposed to be on the asset instead of the task.

I can probably just have the base hook I’m using for workfiles and loader drop down to an asset context from the task context before opening the file.

I probably also need to strip the task off of the context when publishing the custom file out of maya.

1 Like

If your work is going at an asset level, then I would probably setup the workfiles app so that the hierarchy on the tab doesn’t go as far as the Task, so your users are just browsing Assets.

1 Like