@denisT I’ve tested your ideas and I’m still a little bit puzzled…
node1.GetObjectRef() == node2.GetObjectRef() wasn’t giving me the same hash between two instances (which is necessary so == operator will give true) and then, about this one ref1.GetReference(0) == ref2.GetReference(0), I still don’t know how to make a ReferenceMaker from a particular node.
Anyway, so far I’ve come up with this mcve:
import MaxPlus
def node_key(n):
return str(n).split()[-1]
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
instances_and_references = defaultdict(list)
for node in traverse():
os = node.EvalWorldState()
obj_ref = node.GetObjectRef()
key = node.FindNodeFromBaseObject(obj_ref)
instances_and_references[node_key(key)].append(node)
print('-' * 80)
for k, v in instances_and_references.items():
print(k, len(v))
This problem with the above code is that’s just able to distinguish between copies and instances&references…
To test it out:
- Create a scene with a box and copy the box, run
- Create a box instance, run
- Create a box reference, run
- Create a box reference+meshsmooth modifier, run
You should see the outcome from that scene something like:
('<000000003CC4F4F0>', 1)
('<000000003CC51130>', 4)
which obviously is not what I’m looking for, as I want to be sure my file-format will save only unique topological geometry only once and the above code won’t guarantee that.
Any advice to fix the above code?





