Filtering Attributes

Hi there,

I am building a tool for popping up attributes on the selected node. I could use some help with the filtering - there are so many types, compounds, arrays compounds of arrays etc. In the image below - I want to gather the simple compounds like translate, which is working fine on a transform node, however if on a shape node, all the complex attributes are messing things up, I am trying to filter them out in a way that is automatic, rather than having to specify an ignore list.

I am finding it difficult to understand the complexity of the multi, array, compounds and how to filter them. Are there any good articles on the web to improve my knowledge. I have been looking at Maya native scripts for Channel Control etc to help. I am using methods like ignoring ā€˜.’ and ā€˜[’ in the attribute names but it keeps tripping up as I try it on different nodes.

I suppose pointing to learning material on attributes would be the best help? So I can do a bit of research and come back to this and make the tool more robust.

$AED_ATT_LIST= `listAttr -multi  $sel`; 

 for ($a in $AED_ATT_LIST) {
            if (`gmatch $a "*\\[*"`) {print $a; continue;}
            if (`gmatch $a "*.*"`)continue;
            if( `objExists ($sel+"."+$a)`== 0) continue;
            if(`attributeQuery -node $sel -usesMultiBuilder $a`){
                print ("skipping multiBuilder = "+ $a); 
                continue;
            }
            if(`attributeExists $a $sel`==0){
                print ($sel+"."+$a + "attribute doesn't exist or not found"); 
                continue;
            }
            // Keep if it has no parent (standalone scalar)
            // OR if it IS a parent (has children) like translate
            string $parent[] = `attributeQuery -node $sel -listParent $a`;
            int $numChildren[] = `attributeQuery -node $sel -numberOfChildren $a`;
            if (size($parent) == 0 || size($numChildren) > 0) {
                $result[size($result)] = $a;
            }
        }

The attrs you are displaying look like double3 and float3 attribute types to me.

I’d build a list of attribute types to include. You can expand as you solve displaying new types.

and use attributeQuery with the a -type flag to skip ones you have not yet solved the display for. the attribute types are documented under addattr

I’d also probably do this in python / maya.cmds

1 Like