Detect if DAG is a default name


#1

If I have a scene file where these nodes exist

pSphere1, nurbsPlane1, directionalLight1, directionalLight2, locator1, etc etc

Is there a way to programmatically know if the name of the object was never renamed from its default name?

At first I thought that I could get the type of the object and create a node of the same type to get its default name and check against its current name. This actually works for a lot of DG nodes (like multiplyDivide, for example) but this is bad very several reasons and I can’t use it.

I could maintain a list of all of the default names of all DAG objects and that would work for the vanilla Maya objects that I listed above but it won’t account for DAG nodes made by plugins.

Another idea was to run a Maya scriptJob in our environment’s startup. Whenever the DagObjectCreated event is run, the script would get the created object(s) and add a hidden, locked attribute with its original name stored inside. Then when I wanted to “check if default name” later, I could just check the stored attribute’s string with the current name.

This solution doesn’t work well with imports, though. For example if DAG objects are imported and they have non-unique names, like some sphere named “metaball_GEO”, the script will still run and assign “metaball_GEO” as the name to the attribute on that object. The check would later fail because the names are the same, even though the sphere has a name that isn’t pSphere#).

That said, does anyone have a better solution that they could share?