AE ENHANCERS

Expressions/Scripts/Presets
It is currently Fri May 24, 2013 7:51 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Remove All Effects fro all Layers
PostPosted: Sun Apr 24, 2011 2:48 pm 
Offline

Joined: Tue Feb 15, 2011 6:19 pm
Posts: 6
Hi! I try to create a script, which will delete(clear), all efects of all layer from current composition.
Code:
{
  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!


Top
 Profile  
 
 Post subject: Re: Remove All Effects fro all Layers
PostPosted: Sun Apr 24, 2011 8:19 pm 
Offline

Joined: Sat Jun 26, 2004 10:01 am
Posts: 298
Location: Folsom, CA
It you're trying to remove the Effects property group rather than the individual effects. You might have more luck with this:

Code:
{
  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

_________________
http://www.motionscript.com


Top
 Profile  
 
 Post subject: Re: Remove All Effects fro all Layers
PostPosted: Mon Apr 25, 2011 10:11 am 
Offline

Joined: Tue Feb 15, 2011 6:19 pm
Posts: 6
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!


Top
 Profile  
 
 Post subject: Re: Remove All Effects fro all Layers
PostPosted: Mon Apr 25, 2011 10:20 am 
Offline

Joined: Tue Feb 15, 2011 6:19 pm
Posts: 6
Well... I found how I can remove all expressions:
Code:
{

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group