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
Select all abobe/below layers
Moderator: byronnash
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
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 --;
}
}
}
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 ++;
}
}
}
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
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) {
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;
and one for before the playhead;
and just for good measure AT the playhead (not sure if i'll ever need this one...);
thanks Paul
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 ++;
}
}
}
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 --;
}
}
}
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 --;
}
}
}
Even later for the party, but here's my generalized function
Code: Select all
function getLayersByIdx(idx,mode){
//by neex2022 - supports 3 modes: after (or 1), before (or 2), except (or 2) specified index (idx)
var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
for(var j=1; j<=activeItem.numLayers; j++){
var cond=false;
(mode=="after"||mode==1)?cond=(j>idx):null;
(mode=="before"||mode==2)?cond=(j<idx):null;
(mode=="except"||mode==3)?cond=(j!=idx):null;
activeItem.layer(j).selected = cond;
}
return activeItem.selectedLayers;
}
}