Re: [Maya-Python] object1.f[38] in [object2.f[38]] == True?

18 views
Skip to first unread message

Justin Israel

unread,
Feb 25, 2014, 7:53:33 PM2/25/14
to python_in...@googlegroups.com
I don't know much about the PyMel class structures, but it seems something is not defined properly for the __eq__ or __cmp__ methods of the base class, to reflect that they are different objects. There is a lot of inheritance in there so I am not really sure where to trace it back to

f1 = pm.MeshFace("pSphere1.f[0]")
f2 = pm.MeshFace("pSphere2.f[0]")
f3 = pm.MeshFace("pSphere2.f[1]")

# Should be False
print f1 == f2
# True

# Should be False
print f1 == f3
# False




On Wed, Feb 26, 2014 at 12:50 PM, Michael Boon <boon...@gmail.com> wrote:
Hi all,

I have a situation where this happens:

MeshFace(u'foo.f[38]') in [MeshFace(u'pillar_section2_lod0.f[38]')]#Result: True

These are Pymel MeshFaces. The object 'foo' is a result of a boolean operation involving 'pillar_section2_lod0', but the two faces are not the same on each object. I've deleted history on 'foo'.

I'm not sure if the fact that both faces are index 38 is a coincidence or not.

Can someone explain why this might happen? It shouldn't happen, right? Or do I have some misapprehension about MeshFaces?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/99ae04a0-ec47-4c15-9725-b2af0e3a19da%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Marcus Ottosson

unread,
Feb 26, 2014, 1:48:09 AM2/26/14
to python_in...@googlegroups.com
I had a look with inspect

import inspect
import pymel.core as pm

node = pm.MeshFace('pSphere1.f[0]')
print inspect.getsourcelines(node.__eq__)
print inspect.getsourcefile(node.__eq__)


..and it looks like it all comes down to this.

def __eq__(self, other):
        if not hasattr(other, '__apicomponent__'):
            return False
        return self.__apicomponent__().isEqual( other.__apicomponent__().object() )

Defined at general.py:3717


It does have an __apicomponent__ attribute, so it ends up comparing it to other.__apicomponent__().object() which says that it is a:

Result: <maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x0000000038F33E40> > # 





For more options, visit https://groups.google.com/groups/opt_out.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages