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
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.