Expressions/Scripts/Presets

Moderator: byronnash

 
yanez
Topic Author
Posts: 9
Joined: Sun Jul 31, 2005 8:52 am

Select all abobe/below layers

Sat Sep 29, 2012 12:26 pm

Hallo is there any "select all above/below layers"?
Let's say i have a timeline with 100 layers, and i need to insert other 10 layer above the 50th layer.
So i need to select all 49 layers above the 50th and move all them forward in the timeline.
I would like to select the 49th layer and then run a script to add to selection all above layers
without usign the mouse. Thanks
 
Klustre
Posts: 21
Joined: Wed Jul 27, 2011 2:53 am

Re: Select all abobe/below layers

Sat Sep 29, 2012 1:21 pm

You can't select a layer, so you'd directly have to go into moving the layers in the timeline. Is this a fixed value every time?
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Select all abobe/below layers

Sun Sep 30, 2012 4:26 am

Here's a script that will select all layers above a single selected layer. It would be pretty easy to adjust it to do different things. Really you need a script that presents a UI to offer different options, but it isn't really worth the effort. You can just use the Shift key to select a range of layers which would usually be quicker than using a script anyway.

var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
   if (activeItem.selectedLayers.length > 0) {
      var selectedIndex = activeItem.selectedLayers[0].index-1;
      while (selectedIndex > 0) {
         activeItem.layer(selectedIndex).selected = true;
         selectedIndex --;
      }
   }
}
 
Klustre
Posts: 21
Joined: Wed Jul 27, 2011 2:53 am

Re: Select all abobe/below layers

Sun Sep 30, 2012 5:03 am

Oh, nice! Didn't know you could use .selected with layers as well.
 
yanez
Topic Author
Posts: 9
Joined: Sun Jul 31, 2005 8:52 am

Re: Select all abobe/below layers

Sun Sep 30, 2012 5:50 am

Paul Tuersley wrote:
Here's a script that will select all layers above a single selected layer...


Thanks very much i will assign a shortcut. Ctrl alt shift UpArrow.
 
benjapo
Posts: 3
Joined: Fri Feb 21, 2014 9:24 am

Re: Select all abobe/below layers

Wed Feb 26, 2014 8:58 am

Paul Tuersley wrote:
Here's a script that will select all layers above a single selected layer. It would be pretty easy to adjust it to do different things. Really you need a script that presents a UI to offer different options, but it isn't really worth the effort. You can just use the Shift key to select a range of layers which would usually be quicker than using a script anyway.



Hi Paul,

I'm attempting to tweak your script to select all layers below. It currently works, but I'm getting an "out of range" error after running it. Any advice on how to clean this up?
Thanks!

var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
   if (activeItem.selectedLayers.length > 0) {
      var selectedIndex = activeItem.selectedLayers[0].index+1;
      while (selectedIndex > 0) {
         activeItem.layer(selectedIndex).selected = true;
         selectedIndex ++;
         
      }
   }
}
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Select all abobe/below layers

Wed Feb 26, 2014 9:11 am

Because you're now going down the layers instead of up you need to stop when you pass the last layer index, not the first. So the 'while' line should be:
while (selectedIndex <= activeItem.numLayers) {
 
benjapo
Posts: 3
Joined: Fri Feb 21, 2014 9:24 am

Re: Select all abobe/below layers

Wed Feb 26, 2014 9:23 am

Beautiful. Thanks for the quick response!

Who is online

Users browsing this forum: No registered users and 4 guests