PDA

View Full Version : Wait for a plugin to load


dlarsson
09-11-2006, 01:10 PM
Hi!

I'm doing some mel scripting that loads a plugin and then calls a command that is in the plugin. The plugin is quite heavy to load and it takes some time before it's completely loaded, however the script continues executing while the plugin is being loaded.
This means that when calling a command directly after loadPlugin is executed it won't find the command since the plugin is not completely loaded.
Is it possible to wait for a plugin to load completely in some way to avoid calling commands before they are available?

the situation looks a bit like this:

...
loadPlugin "myPlugin.mll";
$jox = `myCmd -jox`;
...

animationrigs
09-11-2006, 05:38 PM
Just a couple of ideas:


check out the -ac flag for loadPlugin
Maybe what you are looking for basically it will define a proc to call after the plugin is loaded.

If that doesn't do it the following might be some potential work arounds
Do a:
whatIs myCmd
then depending on what the result is in mel you can wait for the plugin, this could get dangerous though, you may want to consider a timeout (ie whatif the plugin never loads)

In the plugin,
You could have the plugin define a variable or execute the command as part of the initialize. Then do mel based on that??

JackSMillenium
09-14-2006, 05:24 AM
I've often had trouble when loading a plugin and using it immediately afterwards (but I thought this was fixed in recent versions of Maya - maybe not). I think it's more an issue of the context the script is being run in (as opposed to not waiting long enough for the plugin to load). The workaround which ALWAYS worked (in my cases...) was to wrap the plugin use in an eval call:

loadPlugin "myPlugin.mll";
string $cmd = "myCmd -jox";
$jox = eval($cmd);

Give that a shot...

CGTalk Moderation
09-14-2006, 05:24 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.