I had been tinkering with using the listHistory mel command but the problem with this is that it returns ALL of the history on the mesh object and not just the deformers. My issue was then, how do I distinguish the deformers from the rest of the data? Without a list of every possible deformer Maya offers to compare it to, there's no way I could find them all.
Solution? `nodeType -inherited`
This command along with the -inherited flag will "Return a string array containing the names of each of the base node types inherited by the given object."
Someone pointed out on the forum that all deformers inherit from the "geometryFilter" base node. With this information we can check through each node in the meshes' history and see if it inherits from geometryFilter. With this, we can return a nice, clean list of all the deformers on a mesh object.
// **********************************************************
// Returns All Deformers On A Mesh
global proc string[] jgReturnMeshDeformers (string $mesh) {
// List History
string $history[] = `listHistory $mesh` ;
// Loop And Check If It's A Deformer
string $deformers[] ;
for($node in $history) {
string $types[] = `nodeType -inherited $node`;
if(stringArrayContains("geometryFilter",$types)) {
stringArrayInsertAtIndex(size($deformers),$deformers,$node) ;
}
}
return $deformers ;
}
Download Here: jgReturnMeshDeformers.mel
Another little gem that comes with this method is that it returns them in the current stack order. Bonus!
So far this method is working out very well for my needs. If you find any issues with it or would like to discuss, please leave a comment below.
Tomorrow's post will be about the script I was originally needing this for, which is a procedure to rebuild a blendShape node with only your specified targets. Maya doesn't allow you delete targets from a blendShape node without a hassle, and when it does delete them it leaves empty target indexes and a big mess under the hood. Swing by tomorrow for more about this. Cheers!