@denisT Mmmm, I’ve tested your final solution and the out results look coherent, ie: created a scene with 1 original box and then made a copy/instance/reference out of it:
import MaxPlus
def traverse():
nodes = []
root_node = MaxPlus.Core.GetRootNode()
def _traverse(node):
if node != root_node:
nodes.append(node)
for c in node.Children:
_traverse(c)
_traverse(root_node)
return nodes
n1, n2, n3, n4 = traverse()
import itertools
for x in itertools.combinations(traverse(), 2):
print('-' * 80)
n1, n2 = x
print("Comparing {} with {}".format(n1, n2))
# two nodes are instances or references
print(n1.GetBaseObject() == n2.GetBaseObject())
# two nodes are exact instances:
print(n1.GetObjectRef() == n2.GetObjectRef())
# two nodes are exact references (not instances):
print(n1.GetBaseObject() == n2.GetBaseObject() and n1.GetObjectRef() != n2.GetObjectRef())
Here’s the output of the comparisons:
--------------------------------------------------------------------------------
Comparing INode: Box001, <000000003B8A0C90> with INode: Box002, <000000003B8A1AB0>
False
False
False
--------------------------------------------------------------------------------
Comparing INode: Box001, <000000003B8A0C90> with INode: Box003, <000000003B8A21C0>
True
True
False
--------------------------------------------------------------------------------
Comparing INode: Box001, <000000003B8A0C90> with INode: Box004, <000000003B8A28D0>
True
False
True
--------------------------------------------------------------------------------
Comparing INode: Box002, <000000003B8A1AB0> with INode: Box003, <000000003B8A21C0>
False
False
False
--------------------------------------------------------------------------------
Comparing INode: Box002, <000000003B8A1AB0> with INode: Box004, <000000003B8A28D0>
False
False
False
--------------------------------------------------------------------------------
Comparing INode: Box003, <000000003B8A21C0> with INode: Box004, <000000003B8A28D0>
True
False
True
I’ll continue testing out a little bit more… before your suggestion I was hashing the whole topological information of all triangular meshes and realized that way was quite expensive operation, ie: dumping less than 100 teapots took like 30s! that’s just crazy slow… so i’d prefer identify similar objects by making unexpensive comparisons like the ones suggested.
By the way, when you’re doing those == comparisons, would you say is fair to think the raw pointers are the ones being compared? 