Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Override requires call or intercept unavailable plugin load

Override requires call or intercept unavailable plugin load

szabolcs.horvatth
Contributor Contributor
1,755 Views
5 Replies
Message 1 of 6

Override requires call or intercept unavailable plugin load

szabolcs.horvatth
Contributor
Contributor

Hi,

 

We have lots of issues with accumulating unused (and unavailable) plugin requirements in Maya scenes that take very long time to check all plugin paths.

(They are usually coming from scene files that we receive from other studios and are simply accumulated junk.) These can be removed since Maya 2015 sp5 from the current scene using "unknownPlugin -remove" but when dealing with hundred thousands of existing and backed up/restored files its a major pain in the **** to do reliably. Before Maya 2015 we simply overrode the requires command with a custom script that had a plugin "blacklist" to skip, but from Maya 2015 the syntax of the requires command changed and as far as I know it can't be overriden by MEL, because instead of using two strings as input, its using a varying attribute structure.

 

My question is: is there a way to get rid of the requires command of some plugins at scene load time? Can I use a callback or something to intercept the requires call? Or is there a way to override the requires command that can handle varying attributes?

 

Cheers,

Szabolcs

0 Likes
Accepted solutions (1)
1,756 Views
5 Replies
Replies (5)
Message 2 of 6

RFlannery1
Collaborator
Collaborator

We run a script when Maya starts up, that adds a callback for the "PostSceneRead" event.  Then in our callback, we remove the plugins automatically.  Something like:

# This script is run once on Maya startup
import maya.OpenMaya as om om.MEventMessage.addEventCallback('PostSceneRead', openFileCallback)

def openFileCallback(_):
unknownPlugins = cmds.unknownPlugin(q=True, list=True)
# blah, blah, remove any unknown plugins that are on the blacklist

Of course, the above example is in Python.  If you want to use MEL, you may be able to do something similar using the "SceneOpened" event of the "scriptJob" command.  (Not sure; I haven't tried it.)  Just keep in mind that script jobs don't run in standalone Maya.  So if you are batching through the files in standalone Maya, your unused plugins won't be removed.

0 Likes
Message 3 of 6

szabolcs.horvatth
Contributor
Contributor

Hi! Thanks for the tip! Thats something similar to what we also do but it only executes *after* the actual plugin loading is done. So if you have an asset that you received from another company with 30 missing plugin requirements,than you still have to wait for Maya trying to load all of them from all possible plugin paths, and only after the scene is finally loaded can you remove the requirements from the Maya scene. And in case of referencing the references will also try to pull these plugins in. Thats why I'm trying to intercept the requires call because thats the only thing that happens before the plugins are considered.

 

Cheers,

Szabolcs

0 Likes
Message 4 of 6

RFlannery1
Collaborator
Collaborator
Ah, I see. In our case it works because once we save the file, the unused plugins are gone from the file. So subsequent file opens are much faster. But you are correct that it doesn't remove the unused plugins from referenced files. Also, we are not getting scenes from other companies.
0 Likes
Message 5 of 6

cheng_xi_li
Autodesk Support
Autodesk Support

Hi, 

 

You can't stop Maya from loading a plugin with requires command. Sorry for the bad news.

 

Yours,

Li

0 Likes
Message 6 of 6

szabolcs.horvatth
Contributor
Contributor
Accepted solution
Hi Li, thanks for looking into it! And the official bad news. 🙂 Would be nice if in a future release we could define a plugin "blacklist" that would be skipped by the requires command.