Remove Unselected Layers - error


hi, found this by Glenn Tester
https://www.lightwave3d.com/assets/plugins/entry/layer-tools-2

does anyone know why it can't run ?


@script modeler
@name "Remove Unselected Layers"
@version 2.3

main

{
mesh = Mesh(0);
selmode(USER);
pointcount = pointcount();
polycount = polycount();
BGLayers = lyrbg();


editbegin();
pointids = points;
editend();

for (p = 1; p <= pointcount; p++)
{
SelLayers += mesh.layer(pointids[p]);
}
SelLayers.sortA();
SelLayers.reduce();
lyrsetfg(SelLayers);
lyrsetbg(BGLayers);
}
 

it simply doesn't run. can hardly recall previously released LW Scripts having problems, so not sure what this could be.
 
Last edited:

Sensei

TrueArt Support
This script is ridiculous. It's getting quantity of points in entire object (could be multimillion). Then going through the all points, and adding one by one layer of current point to the list.. So if you have multimillion point object, generated list "SelLayers", will have multimillion entries..
Proper code should go through the all foreground layers, check if they have some points, and whether points are selected by user, if any point is selected in layer, add layer to the list.
 

still, should have worked, since i used it on objects with a total of ~20 polys.

thanks for the info
looks like i'll give this script a rest.
 

Kryslin

Active member
This script may have been written before the .indexOf() function was added.

I agree with Sensei, though, this could be done better.
 
Top Bottom