in Installation by
edited by
Every time I restarted Maya, when I clicked the MGTools shelf button, error issued in the script editor and the tool is not loaded.

I have to reinstall MGTools to make it work, but the same story repeated over and over again after Maya restarted.

1 Answer

0 votes
by
edited by
 
Best answer

There could be many possible reasons:

  1. The Maya autoload scripts "userSetup.mel" and/or "userSetup.py" are banned or somehow readOnly in your production environment.
  2. There are other autoloading code introduce by other tools that cause an error and Maya failed to execute the autoloading code after that line.

Fallback solution: Manually load MGTools

If you don't mind manually loading MGTools, install the code below as MEL or python shelf button and use it to load the tools: (Do remember to replace the "YourPathToMGToolsSource" in the code with the actual file path to MGToolsLoader_WrittenByMiguel.mel)

MEL version:

// This initialize MGTools:
{
  // Replace YourPathToMGToolsSource with your real path:
  string $MGTools_AutoLoaderFile = "YourPathToMGToolsSource/MGToolsLoader_WrittenByMiguel.mel";
  if(`filetest -f $MGTools_AutoLoaderFile`)
  {
    eval ("source \""+$MGTools_AutoLoaderFile+"\";");
  }
}
// This launch MGTools tool bar:
eval (`MG_sourceCommand "MGTools_WrittenByMiguel.mel"`); MGtools;

Python version:

# This initialises MGTools:
import maya.mel as mel
import os
def MGTools_AutoLoad_Py(loaderMel):   
    if os.path.isfile(loaderMel):
        mel.eval('evalDeferred ("source \\\"'+loaderMel+'\\\";")')
# Replace YourPathToMGToolsSource with the real path:
MGTools_AutoLoad_Py('YourPathToMGToolsSource/MGToolsLoader_WrittenByMiguel.mel')

# This loads MGTools:
mel.eval('MG_sourceCommand "MGTools_WrittenByMiguel.mel"; MGtools;')
Once you execute the code above, MGTools is initialised and the tool bar is shown. After that you can use all the other MGTools shelf buttons.

The solution to autoloading issue #1:

When you reinstall MGTools Pro3, try using the "userSetup.py" as the choice for the "Autoload Via File" option. On the contrary, if you used "userSetup.py" before, try using "userSetup.mel" instead. 

With all have been tried, if still not works, check out the "userSetup.mel" or "userSetup.py" file in Maya's user script folder, open it with a text editor, see if there are some codes like so:

For the "userSetup.mel":

//MGautoLoad_start
  string $MGTools_AutoLoaderFile = "YourPathToMGToolsSource/MGToolsLoader_WrittenByMiguel.mel";
  if(`filetest -f $MGTools_AutoLoaderFile`)
  {
    eval ("source \""+$MGTools_AutoLoaderFile+"\";MGToolsAutoLoader;");
  }
//MGautoLoad_end

For userSetup.py:

#MGautoLoad_start
def MGTools_AutoLoad_Py(loaderMel):
    import maya.mel as mel
    import os
    if os.path.isfile(loaderMel):
        mel.eval('evalDeferred ("source \\\"'+loaderMel+'\\\";MGToolsAutoLoader;")')
MGTools_AutoLoad_Py('YourPathToMGToolsSource/MGToolsLoader_WrittenByMiguel.mel')
#MGautoLoad_end

If it does not contain the similar codes above, replace the "YourPathToMGToolsSource" above with the actual file path to MGToolsLoader_WrittenByMiguel.mel, and manually input the codes at the starting of the file userSetup.mel or userSetup.py, save it, and restart Maya see if the issue been addressed.

If everything looks OK but still not work, ask your TD or IT department if the userSetup.mel and userSetup.py are both banned. If they are, MGTools cannot be autoloaded but it can be loaded manually. You need to adopt the manual loading solution above.

The solution to autoloading issue #2:

 Edit "userSetup.mel" or "userSetup.py" with a text editor, move the code including "//MGautoLoad_start ... //MGautoLoad_end" or  "#MGautoLoad_start ... #MGautoLoad_end" to the start of the file to make sure they are executed by Maya first. Or simply remove other codes if you don't need them.

 

...