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

Delete empty layers in Animate?

Explorer ,
Nov 08, 2023 Nov 08, 2023

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!

Views

311

Translate

Translate

Report

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
...

Votes

Translate

Translate
Community Expert ,
Nov 08, 2023 Nov 08, 2023

Copy link to clipboard

Copied

you could use jsfl to do that.

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Wow! That worked perfectly!

Many thanks, dude! ❤️

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Awesome! You're welcome!

Votes

Translate

Translate

Report

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