/* //ks_SaveLightLinkRemover Removes surplus light linkers (common problem when referencing and importing scenes). Keeps Light linkers required to continue ligthing the scene without lightlinking every light source (slow). No GUI. */ ////////////////////////////////////////////////////////////////////////////////////// //////////////////////break connection of given dest attribute global proc breakConnection(string $destName) { if (`connectionInfo -isDestination $destName`) { string $destination = `connectionInfo -getExactDestination $destName`; string $srcConn[] = `listConnections -s 1 -d 0 -type character $destination`; if (size($srcConn)) { string $warnMsg = ("Removed \'"+ $destination +"\' from character \'"+$srcConn[0]+"\'."); warning($warnMsg); character -e -rm $srcConn[0] $destination; } // delete -icn doesn't work if destination attr is readOnly so use disconnectAttr in this case string $sArr[1] = `ls -l -ro $destination`; if (size($sArr)) { string $src = `connectionInfo -sourceFromDestination $destination`; catch(`disconnectAttr $src $destination`); } else { catch(`delete -icn $destination`); } } } ////////////////////////////////////////////////////////////////////////////////////// global proc ks_SaveLightLinkRemover() { string $SG[]=`ls -type shadingEngine`; waitCursor -state on; progressWindow -title "Remove" -isInterruptable true; int $size = `size($SG)`; catch(`progressWindow -e -min 0 -max $size`); for ($i= 0; $i < size($SG); $i++) { string $LL[]=`connectionInfo -dfs ($SG[$i] + ".message")`; //string $xt_isg[] = `listConnections -s 1 -p 1 initialShadingGroup.message`; catch(`progressWindow -e -step 1`); if (size($LL)>= 4) { for ($j= 3; $j < size($LL); $j++) { if (`gmatch $LL[$j] "*lightLinker*"`==1 ) // && `gmatch $LL[$j] "*shadowLink*"`==0 && `gmatch $LL[$j] "*link[0]*"`==0) { breakConnection($LL[$j]); // print ($j + " break_: " + $LL[$j]+"\n"); } } } } progressWindow -endProgress; waitCursor -state off; print ("############### ks_SaveLightLinkRemover completed." +"\n"); }