Maya python 模块的 Eclipse 环境

发布于 2024-10-14 20:17:04 字数 1220 浏览 9 评论 0原文

我正在尝试设置 Eclipse IDE 以识别 ma​​ya.cmds 模块,即与 ma​​ya 模块关联的所有模块。以下代码是在 Eclipse 和 Maya 脚本编辑器中运行的测试。

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

在 Maya 的脚本编辑器中,代码结果为

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>

在 Eclipse 中,代码结果为

maya:
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']

cmds:
6

sphere: 
Traceback (most recent call last):
AttributeError: 'module' object has no attribute 'sphere'

我在 google 组“python inside maya”和网络搜索上进行了大量搜索。我发现的最好的链接是以下链接,但这根本没有解决我的问题,最终给出了相同的结果。 http://www.luma-pictures.com/tools/ pymel/docs/1.0/eclipse.html

我读过,我应该在 Eclipse 中设置我的环境路径,而不是我的机器,而且我也读过相反的意见。我应该设置什么环境变量、在哪里、在 Eclipse、Windows 或两者中设置?

I'm trying to set up the Eclipse IDE to recognize the maya.cmds module, an all modules associated with the maya module. The following code are tests run in Eclipse, and Maya's script editor.

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 Maya's script editor the code results in

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 results in

maya:
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']

cmds:
6

sphere: 
Traceback (most recent call last):
AttributeError: 'module' object has no attribute 'sphere'

I've done a lot of searching, on the google group "python inside maya", and web searches. The best I've found was the following link, however this did not solve my issue at all, and in the end gave the same result. http://www.luma-pictures.com/tools/pymel/docs/1.0/eclipse.html

I've read that I should be setting my environment paths in Eclipse, rather than my machine, and I've also read the opposite opinion. What environment vars should I set, to where, and in Eclipse, Windows, or both?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

汹涌人海 2024-10-21 20:17:04

解决方案是导入maya.standalone并初始化它。
这使您可以访问其中的 Maya 包和模块。

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

输出:

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>

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

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>
痕至 2024-10-21 20:17:04

如果您愿意,可以设置 eclipse 直接在其上运行(调试)maya(当然,使用独立版本)。

如果你使用 python 解释器,你可以添加一个 mayapy 解释器。
new,写下你想要的新内容:D,
解释器可执行文件将是您的 Maya 路径)..\bin\mayapi.exe
(例如:D:\Program Files\Autodesk\Maya2013\bin\mayapi.exe

包含您认为需要的所有模块,然后完成。
现在您可以在 Eclipse 中使用 Maya 解释器,这意味着使用 Maya 独立版,您也可以运行脚本(如果我需要执行类似的递归任务,我喜欢使用这种方式;))。

If you want you can setup eclipse to run (debug) maya directly on it (using standalone, of course).

If you go in python interpreters you can add a mayapy interpreter.
Press new, write the new that you want :D,
interpreter executable will be your maya path ) ..\bin\mayapi.exe
(eg: D:\Program Files\Autodesk\Maya2013\bin\mayapi.exe)

Include all the the modules that you think you need, and done.
now you can use maya interpreter inside eclipse, this it means that with maya standalone, you can run your script as well ( I like to use this way if I need to do a recursive task o similar ;) ).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文