python - 如何导入 PyMEL 内核?

标签 python maya pymel

我正在导入 maya.standalone,对其进行初始化,然后将 pymel.core 作为 pmc 导入到我的 Maya Python 解释器中,该解释器在 powershell 中运行。在这一点上,我收到了很多警告。在我调用:xform, shape = pmc.polysphere() 之后,我收到警告:name 'xform' is not defined

这是 pymel 导入的输出

> Warning: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/initialStartup.mel line 195:
> Y-axis is already the Up-axis Initialized VP2.0 renderer {   Version :
> 6.3.16.0. Feature Level 5.   Adapter : Intel(R) HD Graphics 4600   Vendor ID: 32902. Device ID : 1046   Driver :
> nvwgf2umx.dll:9.18.13.5306.   API : DirectX V.11.   Max texture size :
> 16384 * 16384.   Max tex coords : 32   Shader versions supported
> (Vertex: 5, Geometry: 5, Pixel 5).   Active stereo support available :
> 0   GPU Memory Limit : 2080 MB.   CPU Memory Limit: 15472.7 MB. }
> OpenCL evaluator is attempting to initialize OpenCL. Detected 2 OpenCL
> Platforms:  0: Intel(R) Corporation. Intel(R) OpenCL. OpenCL 1.2 . 
> Supported extensions: cl_intel_dx9_media_sharing
> cl_khr_byte_addressable_store cl_khr_d3d11_sharing
> cl_khr_dx9_media_sharing cl_khr_gl_sharing
> cl_khr_global_int32_base_atomics cl_khr_global
> _int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics  1: NVIDIA Corporation. NVIDIA
> CUDA. OpenCL 1.2 CUDA 7.5.8.  Supported extensions:
> cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing
> cl_nv_compiler_options cl_nv_device_attribute_query
> cl_nv_pragma_unroll cl_nv_d3d9_sharing cl_nv_d3d10_shari ng
> cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts OpenCL
> evaluator choosing OpenCL platform Intel(R) Corporation. Choosing
> OpenCL Device Intel(R) HD Graphics 4600.  Device Type: GPU  Device is
> available. OpenCL device does not support out of order execution
> 
> Error: file: C:/Program
> Files/Autodesk/Maya2016/plug-ins/xgen/scripts/igInitialize.mel line
> 63: ImportError: file <maya console> line 1: No module named xgenm
> Error: Unable to execute igInitialize.mel. Unable to execute
> igInitialize.mel.Error: line 0: ImportError: file <maya console> line
> 1: No module named xgenm Error: Unable to execute xgen.mel. Unable to
> execute xgen.mel.xgmNurbsPatch [u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmP atch',
> u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmNurbsPatch'] pymel.internal.apicache : WARNING
> : lineage for node xgmNurbsPatch is cyclical: [u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u's urfaceShape', u'THsurfaceShape', u'xgmPatch',
> u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u' xgmNurbsPatch'] xgmSubdPatch [u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmPatch',
> u'containerBase', u'e ntity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmSubdPatch'] pymel.internal.apicache : WARNING
> : lineage for node xgmSubdPatch is cyclical: [u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'su rfaceShape', u'THsurfaceShape', u'xgmPatch',
> u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'x gmSubdPatch'] xgmArchiveGuide
> [u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmGuide', u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape',
> u'xgmArchiveGuide'] pymel.internal.apicache : WARNING : lineage for
> node xgmArchiveGuide is cyclical: [u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u 'surfaceShape', u'THsurfaceShape', u'xgmGuide',
> u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmArchiveGuide'] xgmCardGuide [u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmGuide',
> u'containerBase', u'e ntity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmCardGuide'] pymel.internal.apicache : WARNING
> : lineage for node xgmCardGuide is cyclical: [u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'su rfaceShape', u'THsurfaceShape', u'xgmGuide',
> u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'x gmCardGuide'] xgmSphereGuide [u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmGuide',
> u'containerBase', u 'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmSphereGuide'] pymel.internal.apicache :
> WARNING : lineage for node xgmSphereGuide is cyclical:
> [u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u' surfaceShape',
> u'THsurfaceShape', u'xgmGuide', u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u
> 'xgmSphereGuide'] xgmSplineGuide [u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmGuide',
> u'containerBase', u 'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u'surfaceShape',
> u'THsurfaceShape', u'xgmSplineGuide'] pymel.internal.apicache :
> WARNING : lineage for node xgmSplineGuide is cyclical:
> [u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'deformableShape', u'controlPoint', u' surfaceShape',
> u'THsurfaceShape', u'xgmGuide', u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'deformableShape',
> u'controlPoint', u'surfaceShape', u'THsurfaceShape', u
> 'xgmSplineGuide'] AbcExport v1.0 using Alembic 1.5.4 (built May  8
> 2014 13:47:10) Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> ImportError: file <maya console> line 1: No module named
> mtoa.lightFilters
> 
> API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line
> 222 : (kFailure): Unexpected Internal Failure Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> ImportError: file <maya console> line 1: No module named
> mtoa.lightFilters
> 
> API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line
> 222 : (kFailure): Unexpected Internal Failure Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> ImportError: file <maya console> line 1: No module named
> mtoa.lightFilters
> 
> API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line
> 222 : (kFailure): Unexpected Internal Failure Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> ImportError: file <maya console> line 1: No module named
> mtoa.lightFilters
> 
> API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line
> 222 : (kFailure): Unexpected Internal Failure 00:00:00   359MB ERROR  
> | [mtoa] [xgenTranslator] Could not find xgen_procedural in search
> path $ARNOLD_PLUGIN_PATH Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> ImportError: file <maya console> line 1: No module named
> mtoa.api.extensions
> 
> API error detected in plugins\mtoa\extension\ExtensionsManager.cpp at
> line 571 : (kFailure): Unexpected Internal Failure Error: file:
> C:/Program Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel
> line 46: ImportError: file <maya console> line 1: No module named
> mtoa.api.extensions
> 
> API error detected in plugins\mtoa\extension\ExtensionsManager.cpp at
> line 571 : (kFailure): Unexpected Internal Failure Error: file:
> C:/Program Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel
> line 46: ImportError: file <maya console> line 1: No module named
> mtoa.api.extensions
> 
> API error detected in plugins\mtoa\extension\ExtensionsManager.cpp at
> line 571 : (kFailure): Unexpected Internal Failure Error: file:
> C:/Program Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel
> line 46: ImportError: file <maya console> line 1: No module named
> arnold
> 
> API error detected in plugins\mtoa\Main.cpp at line 770 : (kFailure):
> Unexpected Internal Failure 00:00:00   362MB ERROR   | Failed to
> import python module 'arnold' Error: Failed to import python module
> 'arnold' aiSkyDomeLight [u'containerBase', u'entity', u'dagNode',
> u'shape', u'geometryShape', u'locator', u'THlocatorShape',
> u'SphereLocator', u'containerBase', u'entity', u'dagNode', u'shape',
> u'geo metryShape', u'locator', u'THlocatorShape', u'aiSkyDomeLight']
> pymel.internal.apicache : WARNING : lineage for node aiSkyDomeLight is
> cyclical: [u'containerBase', u'entity', u'dagNode', u'shape',
> u'geometryShape', u'locator', u'THlocatorShape', u'Sphere Locator',
> u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'locator', u'THlocatorShape', u'aiSkyDomeLight'] aiSky
> [u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape',
> u'locator', u'THlocatorShape', u'SphereLocator', u'containerBase',
> u'entity', u'dagNode', u'shape', u'geometryShap e', u'locator',
> u'THlocatorShape', u'aiSky'] pymel.internal.apicache : WARNING :
> lineage for node aiSky is cyclical: [u'containerBase', u'entity',
> u'dagNode', u'shape', u'geometryShape', u'locator', u'THlocatorShape',
> u'SphereLocator',  u'containerBase', u'entity', u'dagNode', u'shape',
> u'geometryShape', u'locator', u'THlocatorShape', u'aiSky'] Error:
> file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> initializePlugin function failed (mtoa) AbcImport v1.0 using Alembic
> 1.5.4 (built May  8 2014 13:47:10) BifrostMain plug-in loaded (built Feb 26 2015 18:01:51) Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> ImportError: file C:/Program
> Files/Autodesk/Maya2016/plug-ins/xgen/plug-ins/xgenMR.py line 9: No m
> odule named xgenm Warning: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46:
> Failed to run file: C:/Program
> Files/Autodesk/Maya2016/plug-ins/xgen/plug-ins/xgenMR.py pymel : ERROR
> : Failed to get controlCommand list from xgenMR pymel : ERROR : Failed
> to get modelEditorCommand list from xgenMR pymel : ERROR : Failed to
> get command list from xgenMR pymel : ERROR : Failed to get
> constraintCommand list from xgenMR pymel.core : ERROR : Failed to get
> depend nodes list from xgenMR Error: file: C:/Program
> Files/Autodesk/Maya2016/scripts/startup/autoLoadPlugin.mel line 46: 
> (xgenMR)
> >>>

我正在阅读 Practical Maya Programming 这本书,这是书中的文字:

Now we will start digging into Maya and PyMEL. Let's begin by initializing Maya in the mayapy interpreter so we can use more than just standard Python functionality. We do this by calling maya.standalone.initialize, as shown in the following code:

>>> import maya.standalone
>>> maya.standalone.initialize()
>>> import pymel.core as pmc
>>> xform, shape = pmc.polySphere()

The import of pymel.core will implicitly call maya.standalone.initialize automatically, but I do it explicitly here so it's clear what's going on. In the future, you can generally skip the call to maya.standalone.initialize and just import pymel.core.

There is a lot we can discover about these PyMEL objects, which represent Maya nodes, using basic Python. For example, to see the type of either of our objects, we can use the built-in type function (we will dig much deeper into types later in this chapter).

谁能解释我在解释器中遇到的错误并提供解决方案?

最佳答案

(这不是一个完整的答案,但我是菜鸟,所以我不能发表评论。)

一堆警告,看起来像

xgmNurbsPatch [u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape', u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmPatch', u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape', u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmNurbsPatch']
# Warning: pymel.internal.apicache : lineage for node xgmNurbsPatch is cyclical: [u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape', u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmPatch', u'containerBase', u'entity', u'dagNode', u'shape', u'geometryShape', u'deformableShape', u'controlPoint', u'surfaceShape', u'THsurfaceShape', u'xgmNurbsPatch'] # 

(我认为)是 Maya 2016 的问题,可能不是您需要担心的任何问题。

我在脚本编辑器中工作,而不是使用 maya.standalone。当我将 Pymel 导入 Maya 2016 时,我收到了 6 个针对各种“xgm”类的警告,与您一样。在以前的 Maya 版本中没有发生这种情况。

至于错误,mtoa/Arnold和xgen都是插件(而且你所有的错误似乎都与插件加载有关)。也许你可以禁用它们?抱歉,我没有在主 Maya 应用程序之外使用 Maya Python 解释器。

编辑:我在此处看到其他人(或者您?)在使用 XGen、Arnold 和 Maya 2016 时遇到类似错误: http://forums.cgsociety.org/archive/index.php?t-1287693.html

关于python - 如何导入 PyMEL 内核?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33365251/

相关文章:

python - 检测 Maya 中的属性何时设置关键帧?

Python telnet 连接失败

python - 为什么 scipy.special.hankel1(0, 10**10) 返回 `nan` ?

python - 如何获取选定对象的名称 Python Maya

javascript - 将 Maya 模型导入到 Three.js 场景的最佳方法是什么

python - Maya 窗口使用 python 动态添加行

python - 有没有一种方法可以在不影响代码的情况下缩进 Python

python - 如何在 Maya 中的重复对象上选择特定边缘?

java - 从Python访问Hadoop — java.io.IOException:管道已结束

python - 动态改变 "template"layout.updatemenus[]下拉菜单