Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Initialisation Problem with maya 0.9.3

Help
Simon Eves
2006-11-28
2013-03-24
  • Simon Eves
    Simon Eves
    2006-11-28

    I am trying to use maya 0.9.3 (Maya 8.0, Python 2.4, Windows).

    My understanding is that you do "import maya.initmaya" to initialise the modules. However, this throws...
    _________________________________________________________________________________________________________

    C:\Documents and Settings\Simon\My Documents>python
    Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    C:\Python24\lib\site-packages\maya\api\__init__.py:26: RuntimeWarning: to-Python converter for class MString already registered; second conversion method ignored.
      from maya._api import *
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "C:\Python24\Lib\site-packages\maya\initmaya\__init__.py", line 36, in ?
        from maya import mel
      File "C:\Python24\Lib\site-packages\maya\mel\__init__.py", line 32, in ?
        import maya._mel as _mel
      File "C:\Python24\Lib\site-packages\maya\_mel\__init__.py", line 167, in ?
        _cmdlst = _MGlobal.executeCommandPy('help -list "*"')
    RuntimeError: unidentifiable C++ exception
    _________________________________________________________________________________________________________

    On inspection of what "initmaya" does, this appears to be two separate problems.

    The RuntimeWarning comes from the import of "api", and seems benign in that api.xxx() functions seem to work correctly.

    The remainder comes from the import of "mel", and mel.xxx() functions do NOT work. I believe I am right in thinking that the MEL binding is built programmatically, and the use of _MGlobal.executeCommand() to get a list of MEL commands would seem to be part of this, so if this is throwing an "unidentifiable C++ exception" it probably explains the failure, but that implies that "api" is *not* in fact working properly.

    I tried the Maya 7.0 version with the same results.

    Please advise.

     
    • Simon Eves
      Simon Eves
      2006-11-28

      (slaps head)

      Having RTFM-ed a little, it seems that the "maya" module is not intended for use outside Maya, at least not as written.

      The normal initmaya process loads the modules, but since the "mel" module uses functions in the "api" module, it presumably requires that api.MLibrary.initialize() be called first.

      Calling this after importing "api" but before importing "mel" changed the situation slightly, but it still threw an error...
      ______________________________________________________________________________________________________________

      C:\Documents and Settings\Simon\My Documents>python
      Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from maya import api
      C:\Python24\lib\site-packages\maya\api\__init__.py:26: RuntimeWarning: to-Python converter for class MString already registered; sec
      ond conversion method ignored.
        from maya._api import *
      >>> api.MLibrary.initialize(wantScriptOutput = 1, applicationName = "python", viewLicense = 1)
      <maya._api.MStatus object at 0x06B69880>
      >>> from maya import mel
      Traceback (most recent call last):
        File "<stdin>", line 1, in ?
        File "C:\Python24\Lib\site-packages\maya\mel\__init__.py", line 32, in ?
          import maya._mel as _mel
        File "C:\Python24\Lib\site-packages\maya\_mel\__init__.py", line 172, in ?
          for _i,_src in enumerate(_iterWrapperSource(_cmdlst)):
        File "C:\Python24\Lib\site-packages\maya\_mel\__init__.py", line 133, in _iterWrapperSource
          flags, multiuse, doc = _melutils.parseHelp(help)
        File "C:\Python24\Lib\site-packages\maya\melutils.py", line 40, in parseHelp
          while lines[0]=="":
      IndexError: list index out of range
      ______________________________________________________________________________________________________________

      I hacked melutils.py to append an extra "\n" to the "lines" array before line 40, and then it seems to work.

      Please advise.

       
    • Matthias Baas
      Matthias Baas
      2006-11-29

      As you have already found out yourself you may only use the mel module either from a script that runs within Maya or when Maya is in library mode. It's also correct that you first have to initialize Maya before importing the mel module. The other option to use Maya functionality outside Maya is by using the remote module.

      As to the IndexError exception, this is a genuine bug in melutils.py. It happens when the help string for a MEL command is entirely empty. The odd thing is that this only happens in library mode. When imported from within the GUI the help string contains a message that there is no help string available...!? Also, it only happens with Maya 8 whereas Maya 7 didn't show that problem.
      Anyway, I've just fixed melutils and committed the modification, so the next release will contain the fix.
      Thanks for reporting the problem!

      - Matthias -