//LightLinker ver1.0 //made by Takahiro Nakajima //http://nkj.lib.net/ //You can use this script with your own risk. //Overview; //This script is for making or cutting links between polygon meshes and lights quickly. //How to use; //1)Run this script to show its window. //2)Select objects and lights you want to make or cut links. //3)Click "Unlink Selected" or "Link Selected" to cut or make links. //"Unlink Selected" breaks all lightlinks of selected objects. This means, //meshes of selected aren't illuminated by any lights in your scene, and lights of selected don't illuminate //any objects in your scene. //"Link Selected" makes lightlinks between all meshes of selected and all lights of selected. //For example, //if many lights and polygon objects are in your scene //and you want to make only "light_A" and "light_B" illuminate "object_A", //1)Select "object_A". //2)Click "Unlink Selected". ("object_A" in a rendered image becomes completely dark.) //3)Select "light_A", "light_B" and "object_A". //4)Click "Link Selected". //-------------------------------------------------------------- //-------------------------------------------------------------- //-------------------------------------------------------------- proc string[] pickObjectsFromListByType(string$list[],string$type) { //This picks specified objects from a list. //Types which can be used for $type are below. //mesh,light,joint,nurbsSurface,nurbsCurve string $result[]; clear $result; int $i = 0; string $item; for($item in $list) { string $objType[] = `ls -st $item`; if($objType[1] == "transform") { string $cName[] = `listRelatives -c -type $type $item`; if(`size $cName` > 0) { $result[$i] = $item; $i++; } } else if($objType[1] == $type) { $result[$i] = $item; $i++; } } return $result; } //-------------------------------------------------------------- proc lightLinkCutterMeshAndLight(string $items[]) { //This cuts all links of objects or lights. //$items can contain lights and polygon objects. //-- //Separate $items to polygon objects and lights. string $lights[] = `pickObjectsFromListByType $items "light"`; string $meshes[] = `pickObjectsFromListByType $items "mesh"`; //Cut for lights. string $objects[] = `ls -type "transform"`; string $light; for($light in $lights) { string $object; for($object in $objects) { lightlink -b -l $light -o $object; } } //Cut for meshes. string $sceneLights[] = `ls -type "light"`; string $mesh; for($mesh in $meshes) { string $sceneLight; for($sceneLight in $sceneLights) { lightlink -b -l $sceneLight -o $mesh; } } } //-------------------------------------------------------------- proc lightLinkMakerMeshAndLight(string $items[]) { //This makes links between all meshes and all lights in $items; //-- //Separate $items to polygon objects and lights. string $lights[] = `pickObjectsFromListByType $items "light"`; string $meshes[] = `pickObjectsFromListByType $items "mesh"`; if((`size $lights`>0)&&(`size $meshes`>0)) { //make links; string $light; string $mesh; for($light in $lights) { for($mesh in $meshes) { lightlink -m -l $light -o $mesh; } } } } //-------------------------------------------------------------- proc lightLinkerExec(int $type) { //This is an executer for this script. //-- string $list[] = `ls -sl`; if($type == 0) { lightLinkCutterMeshAndLight $list; } else if($type == 1) { lightLinkMakerMeshAndLight $list; } } //------------------------------------- //Make a window. { string $title = "LightLinker"; string $object = "LightLinkerObject"; if(`window -ex $object` == 1) { deleteUI $object; } window -t $title $object; columnLayout -p $object "layout"; //----- text -l "LightLinker ver1.0"; separator -w 90; //----- text -l ""; button -w 90 -c "lightLinkerExec 0" -l "Unlink Selected"; text -l ""; button -w 90 -c "lightLinkerExec 1" -l "Link Selected"; window -e -w 90 -h 140 $object; showWindow $object; } //------------------------------------- //The end of the script.