【问题标题】:Eclipse environment for Maya's python modulesMaya 的 python 模块的 Eclipse 环境
【发布时间】:2011-06-17 23:47:57
【问题描述】:

我正在尝试设置 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 或两者中设置什么环境变量?

【问题讨论】:

    标签: python eclipse environment maya


    【解决方案1】:

    解决方法是导入 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>
    

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-10
        • 1970-01-01
        • 2013-09-12
        • 2020-08-26
        • 1970-01-01
        相关资源
        最近更新 更多