Select all abobe/below layers

What type of scripts do you need?

Moderator: byronnash

Post Reply
yanez
Posts: 9
Joined: July 31st, 2005, 8:52 am

September 29th, 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: July 27th, 2011, 2:53 am

September 29th, 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: June 5th, 2004, 7:59 am
Location: London, UK

September 30th, 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.

Code: Select all

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: July 27th, 2011, 2:53 am

September 30th, 2012, 5:03 am

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

September 30th, 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: February 21st, 2014, 9:24 am

February 26th, 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!

Code: Select all

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: June 5th, 2004, 7:59 am
Location: London, UK

February 26th, 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:

Code: Select all

while (selectedIndex <= activeItem.numLayers) {
benjapo
Posts: 3
Joined: February 21st, 2014, 9:24 am

February 26th, 2014, 9:23 am

Beautiful. Thanks for the quick response!
apeshake
Posts: 1
Joined: February 6th, 2018, 11:26 am

February 6th, 2018, 11:32 am

Hey, a bit late to the party but i just came across this thread and modified your script to make a select layers after playhead script I'd been searching for;

Code: Select all

{
var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
      var selectedIndex = 1;
      while (selectedIndex <= activeItem.numLayers) {
          if (activeItem.layer(selectedIndex).inPoint > activeItem.time) {
            activeItem.layer(selectedIndex).selected = true;
          } else {
            activeItem.layer(selectedIndex).selected = false;
          }
        selectedIndex ++;
      }
}
}
and one for before the playhead;

Code: Select all

{
var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
      var selectedIndex = activeItem.numLayers;
      while (selectedIndex > 0) {
          if (activeItem.layer(selectedIndex).inPoint < activeItem.time) {
            activeItem.layer(selectedIndex).selected = true;
          } else {
            activeItem.layer(selectedIndex).selected = false;
          }
        selectedIndex --;
      }
}
}
and just for good measure AT the playhead (not sure if i'll ever need this one...);

Code: Select all

{
var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
      var selectedIndex = activeItem.numLayers;
      while (selectedIndex > 0) {
          if (activeItem.layer(selectedIndex).inPoint == activeItem.time) {
            activeItem.layer(selectedIndex).selected = true;
          } else {
            activeItem.layer(selectedIndex).selected = false;
          }
        selectedIndex --;
      }
}
}
thanks Paul
Post Reply