PDA

View Full Version : MEL script to kill Light Linking mess in .MA files


AcmeImages
01-19-2011, 08:19 PM
Ever get 40,000 lines of code in an .ma file, that resemble something like this and makes your scene file drag ass:

connectAttr ":initialShadingGroup.msg" "lightLinker1.slnk[0].solk";
connectAttr ":defaultLightSet.msg" "lightLinker1.slnk[1].sllk";
connectAttr ":initialParticleSE.msg" "lightLinker1.slnk[1].solk";

I used to have a script to could clean this up, but of course I can't find it when I need it.

Thanks ahead of time....

Chris

thematt
01-19-2011, 09:47 PM
i'd be intersting on that too, because it happens sometime and it's really annoying!

dushyantk
01-20-2011, 07:14 AM
Anybody found this script, or any other way to deal with this? 'd be seriously useful :deal:

rahulsg2901
01-20-2011, 08:01 AM
Attach one example file which has light liking issue. Let me try

r4inm4ker
01-20-2011, 08:18 AM
{
string $allLightLinkers[] = `ls -type "lightLinker"`;

for($eachLightLinker in $allLightLinkers)
{
string $allConnections[] = `listConnections -connections 1 -plugs 1 $eachLightLinker`;
int $i=0;
for($i=0;$i<size($allConnections);$i+=2)
{
string $test1 ="disconnectAttr "+$allConnections[$i+1]+" "+$allConnections[$i];
catchQuiet(eval($test1));
}
}
print("script done.\n");
}



it'll delete all the light linking, even the default one. So after performing the script, the rendered scene will be all black. To solve this, just save the scene and reopen it. Maya will auto-generate the default light-link.

Maybe there's other better solution out there. But hope this helps in case of someone needs it.

thematt
01-20-2011, 01:29 PM
found that, not the script but already a good help to know what to edit in the .ma in case of this happening, now one could probably do a script that search though the .ma and do the deleting altogether.

cheers

http://gokhanertem.net/tutorials/MAYA/Saving_and_Opening_Files_Takes_Forever/Saving_and_Opening_Files_Takes_Forever.html

AcmeImages
01-20-2011, 03:52 PM
Thanks Jefri, I will try that out tonight when I get home.....


{
string $allLightLinkers[] = `ls -type "lightLinker"`;

for($eachLightLinker in $allLightLinkers)
{
string $allConnections[] = `listConnections -connections 1 -plugs 1 $eachLightLinker`;
int $i=0;
for($i=0;$i<size($allConnections);$i+=2)
{
string $test1 ="disconnectAttr "+$allConnections[$i+1]+" "+$allConnections[$i];
catchQuiet(eval($test1));
}
}
print("script done.\n");
}



it'll delete all the light linking, even the default one. So after performing the script, the rendered scene will be all black. To solve this, just save the scene and reopen it. Maya will auto-generate the default light-link.

Maybe there's other better solution out there. But hope this helps in case of someone needs it.

AcmeImages
01-22-2011, 02:59 AM
Attach one example file which has light liking issue. Let me try

I can't post the file for confidential reasons, but here is some of the code:

connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24940].llnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24940].olnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24941].llnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24941].olnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24942].llnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24942].olnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24943].llnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24943].olnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24944].llnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24944].olnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24945].llnk";
connectAttr ":initialShadingGroup.msg" "lightLinker1.lnk[24945].olnk";

notice the number in the brackets? Thats the numer of times the message appears, times 2 because each line has a .olnk and a llnk

tathu
04-15-2011, 02:55 PM
http://www.creativecrash.com/maya/downloads/scripts-plugins/c/rem_lightlink

I just found this at Creativecrash.

AcmeImages
04-15-2011, 03:01 PM
Thanks for that, looks great!

Mark-J
04-15-2011, 03:40 PM
Be careful with removing lightlinks in Maya2011, there were some stability issues introduced that can make scenes very unstable after running something like this. We used a similar script in production up till 2010 but removed it in 2011 because of this. Not tried it in 2012 yet mind you.

Mark

CGTalk Moderation
04-15-2011, 03:40 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.