Two Python objects that wrap the same Max Node, should be considered equal, but not identical.
Following this “==” and “in” should successfully test for equality of two or more Python objects that wrap the same 3dsMax Node.
However “is” should fail, as this checks if two Python objects are the same, not equivalent.
In MaxPlus for 3dsMax 2014 Extension, this is unfortunately not the behavior your get (2015 and forward seems to addresses that). Something to be aware of, or you might think you have Gremlins in your code.
This means you have to find some way to check for equivalence yourself (In Max we obviously cannot rely on naming). I’ve monkey patched INode, with the following code, but a solution that handles all wrapped Max nodes would be preferable. Let me know if you have suggesting for how to do that (I’m a Max & MaxPlus noob).
def __eq__(self, other):
----if self.GetHandle() == other.GetHandle():
MaxPlus.INode.__eq__ = __eq__
Hashing is also “broken”. If you want to be able to use INodes as dictionary keys you might want to implement __hash__ as well:
def __hash__(self): return self.GetHandle()
MaxPlus.INode.__hash__ = __hash__
According to this http://stackoverflow.com/questions/327311/how-are-pythons-built-in-dictionaries-implemented dictionary key insertion and retrieval is based upon Hash; then Equivalence, so should be good.
All in all a nasty hack to a somewhat nasty Python implementation. You could of course simply do equality by comparing Object Handles and also use these as dictionary keys, but what’s the fun in that? 🙂