Home Technical Talk

Get material count of a given mesh in Maya 2012?

bpears
polycounter lvl 4
Offline / Send Message
bpears polycounter lvl 4
Hello. Is there a way to find all materials used within a single mesh ? I want to be sure I do not have extra materials from other parts mixed around and whatnot.

Replies

  • Bartalon
    Options
    Offline / Send Message
    Bartalon polycounter lvl 12
    You can use this short script to report the number and names of materials assigned to your object, just select your object and enter this into the MEL command line at the bottom of the window (or turn it into a shelf button if you'd like):
    {
        string $select[] = `ls -sl`;
        string $assigned[];
    
        for ($e=0; $e<`size $select`; ++$e) {
            string $shapes[] = `listRelatives -children -f -shapes $select[$e]`;
            string $SE[] = `listConnections -type shadingEngine $shapes[0]`;
            $SE = stringArrayRemoveDuplicates($SE);
            for ($i=0; $i<`size $SE`; ++$i) {
                string $surfaceShader[] = `listConnections ($SE[$i] + ".surfaceShader")`;
                if ($surfaceShader[0] == "" && `objExists ($SE[$i] + ".miMaterialShader")`) { 
                    $surfaceShader = `listConnections ($SE[$i] + ".miMaterialShader")`; 
                }
                if ($surfaceShader[0] != "") { $assigned = stringArrayCatenate($assigned, $surfaceShader); }
            }
        }
        print (`size($assigned)` + " Materials:  " + (stringArrayToString($assigned, " - ")));
    }
    
    
  • bpears
    Options
    Offline / Send Message
    bpears polycounter lvl 4
    awesome, thank you.
  • oglu
    Options
    Offline / Send Message
    oglu polycount lvl 666
    open the hypershade and klick the icon with the blue ball and the green square...

    or use the node editor... RMB making menue and swipe down...
Sign In or Register to comment.