Hello!
I’ve been writing quite a few tools in Maya lately, and I’ve come across this same problem multiple times, but I don’t know how to solve it.
Basically, there are many times when I want to hang onto references to some transform nodes, and keep a list widget of all their up-to-date names. If you change the name or parent of the node in Maya itself, this list widget instantly updates to show the new name. It would let you keep a sub-selection on hand at all times, neat!
I have gotten close by using OpenMaya to get a reference to the actual nodes that would appear in the list.However, my listwidget is not updated by Maya when the node’s name changes. I still have to query all the nodes in the widget about once a second to get their names, and then update the list if they changed. This is obviously not ideal, and it creates all sorts of crashes when dealing with opening other scenes, pressing undo/redo, etc.
To me, it would seem that my only option is to write a custom openmaya node that I would then connect with Plugs to the name attribute of the transform nodes. And then in the compute method of my custom node, I would send a signal to the listWidget with the new name.
But this will dirty up the node graph, and it will leave all these nodes behind when you close the tool. What happens if you open it again, or if two tools each create a copy of that node? It sounds like it would turn into a horrible mess and have bad perf impact.
Does anyone know how to create this behavior without creating a ton of nodes?
Thanks for any thoughts you have!