Maya- find node names that are not unique

Sometimes you can end up in situations where Maya Nodes don't have unique names. Usually this won't cause issues until you are doing global changes (like the hack amazing workaround where you remove namespaces on export)

Shawn Miller put me onto this handy little snippet to identify nodes that don't have Unique names:

string $allDagNodes[] = `ls -sn -dag`;
for ($node in $allDagNodes)
if (`gmatch $node "*|*"`)
print ($node+" is not uniquely named");

Thanks Shawn!

2 comments:

  1. ahhhh! mel! my EYES!

    ```
    import maya.cmds as cmds
    from collections import defaultdict

    def non_unique_names():
    multiples = defaultdict(list)

    for node in iter(cmds.ls(dag=True, l=True)):
    multiples[node.rpartition("|")[-1]].append(node)

    return (v for v in multiples.values() if len(v) > 1)


    for item in non_unique_names():
    print item
    ```

    ReplyDelete

Comments?