Copy link to clipboard
Copied
Hi there!
I'm sure this topic go through many apps, not only Animate.
Many time I receive layouts with many empty layers and of course I delete them, but there also are inbetween some non empty layers, so I have to select one by one in order to delete them.
So, is there a way to delete empty layers automatically in Animate?
Thanks in advance!
This one will delete the selected layers in the current timeline:
var doc = fl.getDocumentDOM();
var timeline = doc.getTimeline();
var layers = timeline.layers;
var selectedLayers = timeline.getSelectedLayers().reverse();
selectedLayers.forEach(function(selectedLayerIndex)
{
var isEmpty = true;
var layer = layers[selectedLayerIndex];
layer.frames.some(function(frame, index)
{
if (!frame.isEmpty)
{
isEmpty = false;
return true;
}
});
if (isEmpty)
timeline.deleteLayer(sele
...
Copy link to clipboard
Copied
you could use jsfl to do that.
Copy link to clipboard
Copied
Hi.
This JSFL script will delete all empty layers in the whole document. Make sure to save your file first and/or to create a backup copy.
https://github.com/joao-cesar/adobe/tree/master/animate%20cc/jsfl/remove_all_empty_layers
Just download it and double-click on it to run.
Regards,
JC
Copy link to clipboard
Copied
This one will delete the selected layers in the current timeline:
var doc = fl.getDocumentDOM();
var timeline = doc.getTimeline();
var layers = timeline.layers;
var selectedLayers = timeline.getSelectedLayers().reverse();
selectedLayers.forEach(function(selectedLayerIndex)
{
var isEmpty = true;
var layer = layers[selectedLayerIndex];
layer.frames.some(function(frame, index)
{
if (!frame.isEmpty)
{
isEmpty = false;
return true;
}
});
if (isEmpty)
timeline.deleteLayer(selectedLayerIndex);
});
This one will delete all empty layers in the current timeline:
var doc = fl.getDocumentDOM();
var timeline = doc.getTimeline();
var layers = timeline.layers.reverse();
var total = layers.length;
var count = 0;
var deleted = 0;
layers.forEach(function(layer)
{
count++;
if (layer.layerType !== "folder")
{
var isEmpty = true;
layer.frames.some(function(frame)
{
if (!frame.isEmpty)
{
isEmpty = false;
return true;
}
});
if (isEmpty)
{
timeline.deleteLayer(total - count);
deleted++;
}
}
});
fl.trace(deleted + " of " + layers.length + " layer(s) deleted.");
Regards,
JC
Copy link to clipboard
Copied
Wow! That worked perfectly!
Many thanks, dude! ❤️
Copy link to clipboard
Copied
Awesome! You're welcome!