code-google-com / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

ls(type="transform") gives error if a nucleus node exists #285

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Maya 2012 SAP, Linux (CentOS 6.2)

If a nucleus node exitst in the scene the ls command fails if you use it with 
PyMel

===== Repro =====
1.create a polyplane
2.select the plane and create nCloth
3.run these two scripts and compare

from pymel.core import *
print [node for node in ls(type="transform")]
# Error: KeyError: MObjectHandle # 

import maya.cmds as cmds
print [node for node in cmds.ls(type="transform")]
[u'front', u'nCloth1', u'nucleus1', u'null1', u'pPlane1', u'persp', u'side', 
u'top']

Original issue reported on code.google.com by ste...@madcrew.se on 25 Sep 2012 at 1:48

GoogleCodeExporter commented 9 years ago
the above works fine for me... could you turn on stack traces (in the script 
editor, go to the menu History >> Show Stack Trace (and you may as well turn on 
"Line numbers in errors" as well, if it isn't already), and then post the 
result?

Original comment by elron...@gmail.com on 26 Sep 2012 at 9:32

GoogleCodeExporter commented 9 years ago
i am getting this error as well whenever i have a nucleus node in the scene.

from pymel.core import *

scene = ls(tr =True)

print scene

# Error: MObjectHandle
# Traceback (most recent call last):
#   File "<maya console>", line 6, in <module>
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
75, in __repr__
#     return u"nt.%s(%r)" % (self.__class__.__name__, self.name())
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
90, in name
#     return self._updateName()
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
79, in _updateName
#     self.__apimobject__()
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
137, in __apimobject__
#     handle = self.__apihandle__()
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
143, in __apihandle__
#     return self.__apiobjects__['MObjectHandle']
# KeyError: 'MObjectHandle' # 

Original comment by art...@thepra.com.au on 8 Oct 2012 at 3:24

GoogleCodeExporter commented 9 years ago
The following works in the latest branch:

import pymel.core as pm
pm.newFile(f=1)
pm.createNode('nucleus')
pm.ls(tr=1)

...and gives me this:

[nt.Transform(u'front'),
 nt.Nucleus(u'nucleus1'),
 nt.Transform(u'persp'),
 nt.Transform(u'side'),
 nt.Transform(u'top')]

going to mark as fixed...

Original comment by elron...@gmail.com on 17 Oct 2012 at 2:21

GoogleCodeExporter commented 9 years ago
Hi,

Same problem here.

import pymel.core as pm
pm.createNode('nucleus')

gives me this:

# Traceback (most recent call last):
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\maya\utils.py", line 357, in 
_guiResultHook
#     return formatGuiResult(obj)
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\internal\startup.py", 
line 74, in myResultCallback
#     return pprint.pformat(obj)
#   File "C:\Program Files\Autodesk\Maya2012\bin\python26.zip\pprint.py", line 
59, in pformat
#   File "C:\Program Files\Autodesk\Maya2012\bin\python26.zip\pprint.py", line 
111, in pformat
#   File "C:\Program Files\Autodesk\Maya2012\bin\python26.zip\pprint.py", line 
129, in _format
#   File "C:\Program Files\Autodesk\Maya2012\bin\python26.zip\pprint.py", line 
223, in _repr
#   File "C:\Program Files\Autodesk\Maya2012\bin\python26.zip\pprint.py", line 
235, in format
#   File "C:\Program Files\Autodesk\Maya2012\bin\python26.zip\pprint.py", line 
320, in _safe_repr
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
75, in __repr__
#     return u"nt.%s(%r)" % (self.__class__.__name__, self.name())
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
90, in name
#     return self._updateName()
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
79, in _updateName
#     self.__apimobject__()
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
137, in __apimobject__
#     handle = self.__apihandle__()
#   File "C:\Program 
Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\core\nodetypes.py", line 
143, in __apihandle__
#     return self.__apiobjects__['MObjectHandle']
# KeyError: 'MObjectHandle'
# Result:  # 

Original comment by contact....@gmail.com on 10 Jun 2013 at 5:27

GoogleCodeExporter commented 9 years ago
This should have been fixed in this revision:
e582b3bac60159f7d09fa826e8213c794e4ec4e0

The root of the problem was a bug in the Maya api - prior to 2014, even though 
nucleus nodes were dag/transform nodes (ie, they could parented under other 
nodes, etc), the API didn't consider them dag nodes - ie, they weren't 
compatible with MFnDagNode.

Anyway, this commit should be in 1.0.5 - so if you're using that version (or 
later), and this bug still persists, let me know, and I'll re-open the ticket...

Original comment by elron...@gmail.com on 18 Jun 2013 at 4:26