Reconnect attributes textures and materials

Quick MEL script to quickly re-connect existing texture connections from one slot to another within multiple materials. To use, alter the script to determine the attributes to connect/disconnect, then select multiples materials and run the script.

As defaults, the script is set to get the first input node it can find, its outColor attribute, re-connect it to the material’s ambientColor attribute. Then, it disconnects that input node’s outColor attribute from the material’s color attribute.

It should work, but it’s admittedly a very sketchy script. Well, until I find time to improve it. Cheers!

global proc rf_reconnect(){
    string $sel[] = `ls -sl`;
    for ($item in $sel) {
        string $srccon[] = `listConnections -s 1 -d 0 $item`;
        connectAttr -f ($srccon[0] + ".outColor") ($item + ".ambientColor"); //Create New Connection
        disconnectAttr ($srccon[0] + ".outColor") ($item + ".color"); //Remove Old Connection
    }
}    
rf_reconnect();
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *