Remove All Effects fro all Layers

What type of scripts do you need?

Moderator: byronnash

Post Reply
taravasya
Posts: 6
Joined: February 15th, 2011, 6:19 pm

Hi! I try to create a script, which will delete(clear), all efects of all layer from current composition.

Code: Select all

{
  var myComp = app.project.activeItem;
  myLayers = myComp.layers;

  for (var i = 1; i <= myLayers.length; i++)
   {
   myLayers[i].Effects.remove();
   }
}
With this script, i have error:
Image
Pleas help me!
Dan Ebberts
Posts: 319
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

It you're trying to remove the Effects property group rather than the individual effects. You might have more luck with this:

Code: Select all

{
  var myComp = app.project.activeItem;
  var myEffects;

  for (var i = 1; i <= myComp.numLayers; i++){
    try{
      myEffects = myComp.layer(i).Effects;
      for (j = myEffects.numProperties; j > 0; j--){
        myEffects.property(j).remove();
      }
    }catch(err){
    }
  }
}

Dan
taravasya
Posts: 6
Joined: February 15th, 2011, 6:19 pm

Thanks Dan! It`s work perfect!!!

I think, I need else reset all settings, remove all keyframes and expressions on timeline from script.... :(
Can you do this script?
Thanks again!
taravasya
Posts: 6
Joined: February 15th, 2011, 6:19 pm

Well... I found how I can remove all expressions:

Code: Select all

{

var comp = app.project.activeItem;

if ((comp != null) && (comp instanceof CompItem))

{
	for (var i=1; i<comp.layers.length; i++)
	{
		recurse_children(comp.layers[i]);
	}

	app.endUndoGroup();
}
else
	alert('no comp selected');

function recurse_children(propParent)
{
	if (propParent != null)
	{
		var prop;
		
		for (var i=1; i<=propParent.numProperties; i++)
		{
			prop = propParent.property(i);
			switch (prop.propertyType)
			{
				case PropertyType.PROPERTY:
					// do action
                if (prop.canSetExpression && prop.expression) prop.expression = '';
					break;
				case PropertyType.INDEXED_GROUP:
					recurse_children(prop);
					break;
				case PropertyType.NAMED_GROUP:
					recurse_children(prop);
					break;
				default:
					break;
			}
		}
	}
}


}
It`s work!
Now I still need to reset settings and remove all keyframes.. (ofcause if it`s possible).
Post Reply