Clear out the dead wood from the layer manager
Occasionally, you end up with a load of layers in your scene that are no use to anybody, serve no function to society, and end up taking valuable space like an unwanted uncle at a wedding.
Here is a macro that will check the layer manager interface and remove any layer that is empty.
tooltip:"Clear Empty Layers"
DeletedLayerCount = 0
local deflayer = layermanager.getlayer 0
deflayer.current = true
for i = Layermanager.count-1 to 1 by-1 do
layer = layermanager.getLayer i
local thislayername = layer.name
if thenodes.count== 0 then (LayerManager.deleteLayerbyname thislayername;DeletedLayerCount +=1)
if not DeletedLayerCount == 0 then Messagebox ("Number of layers removed – " + DeletedLayerCount as string) title:"Layer Manager"
The ampersand before the variable declares an array to be used and populates it with the layer contents. You might also notice that it deletes the layers in reverse order, since each time you delete one, the layer count becomes less. So if you deleted it going forward you would probably reach a point where the loop integer would be higher than the number of remaining layers, boo.
You also have to minus one from the total count as the default layer is located at 0.