Eclipse environment for mya python modules

I am trying to configure the Eclipse environment to recognize the maya.cmds module, all modules associated with the Maya module. The following code is the tests run in the Eclipse editor and the Maya script.

import maya print 'maya:\n', dir(maya) from maya import cmds print 'cmds:\n', len(dir(cmds)) # too many to print print 'sphere: ', cmds.sphere 

In the Maya editor, the script outputs

 maya: ['OpenMaya', '_OpenMaya', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'app', 'cmds', 'mel', 'standalone', 'stringTable', 'utils'] cmds: 3190 sphere: <built-in method sphere of module object at 0x0000000019F0EEE8> 

In Eclipse, the code leads to

 maya: ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__'] cmds: 6 sphere: Traceback (most recent call last): AttributeError: 'module' object has no attribute 'sphere' 

I searched a lot in google group "python inside maya" and in web search. The best I found was the following link, however this did not solve my problem at all, and ended up giving the same result. http://www.luma-pictures.com/tools/pymel/docs/1.0/eclipse.html

I read that I need to set up the environment paths in Eclipse and not on my machine, and I also read the opposite view. What vars environments should be installed, where and in Eclipse, Windows, or both?

+4
source share
2 answers

The solution is to import maya.standalone and initialize it. This gives you access to Maya packages and modules.

 import maya.standalone maya.standalone.initialize() import maya print 'maya:\n', dir(maya) from maya import cmds print 'cmds:\n', len(dir(cmds)) # too many to print print 'sphere: ', cmds.sphere 

output:

 maya: ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'app', 'cmds', 'mel', 'standalone', 'stringTable', 'test', 'utils'] cmds: 2945 sphere: <built-in method sphere of module object at 0xf33948> 
+3
source

If you want, you can configure eclipse to run (debug) Maya directly on it (of course, using the stand-alone interface).

If you go to python interpreters, you can add a mayapy interpreter. Click new , write the new one that you want: D, the executable file of the interpreter will be your Mayan path) ..\bin\mayapi.exe (for example: D:\Program Files\Autodesk\Maya2013\bin\mayapi.exe )

Turn on all the modules you think you need and do it. now you can use the Maya interpreter inside eclipse, which means that with Maya autonomous you can also run your script (I like to use this way if I need to do the recursive task o in a similar way;)).

+2
source

Source: https://habr.com/ru/post/1337637/


All Articles