Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Delete empty layers in Animate?

Explorer ,
Nov 08, 2023 Nov 08, 2023

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!

557
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 08, 2023 Nov 08, 2023

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
...
Translate
Community Expert ,
Nov 08, 2023 Nov 08, 2023

you could use jsfl to do that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2023 Nov 08, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2023 Nov 08, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2023 Nov 08, 2023

Wow! That worked perfectly!

Many thanks, dude! ❤️

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2023 Nov 08, 2023
LATEST

Awesome! You're welcome!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines