Skip to main content
Dodamfafa
Participant
July 21, 2022
Answered

Q) work area end expression or script

  • July 21, 2022
  • 1 reply
  • 513 views

Hi. There's a lot of searching in the community.
I'm trying to solve the problem below using a script.

 

I want to put the indicator in a specific layer and finish the work area end.

For example, as shown in the attached photo,
When there's a layer of '01~06', I want to set the working area only to the activated '01~04' layer.

 

What method and script should I write to solve my problem?

This topic has been closed for replies.
Correct answer Dan Ebberts

More like this then, maybe:

var myComp = app.project.activeItem;
var maxLayer = null;
for (var i = 1; i <= myComp.numLayers; i++){
	if (myComp.layer(i).hasVideo && myComp.layer(i).enabled){
		if (maxLayer == null){
			maxLayer = myComp.layer(i);
			continue;
		}
		if (myComp.layer(i).outPoint > maxLayer.outPoint){
			maxLayer = myComp.layer(i);
		}
	}
}
if (maxLayer != null){
	myComp.time = maxLayer.outPoint;
	myComp.workAreaStart = 0;
	myComp.workAreaDuration = maxLayer.outPoint;
}

1 reply

Dan Ebberts
Community Expert
Community Expert
July 21, 2022

It could be something like this, for this specific example, but it could be a lot more complicated, depending on exactly what the rules are:

var myComp = app.project.activeItem;
try{
	var myLayer = myComp.layer("04.jpg");
	myComp.time = myLayer.outPoint;
	myComp.workAreaStart = 0;
	myComp.workAreaDuration = myLayer.outPoint;
	for (var i = 1; i < myLayer.index; i++){
		if (myComp.layer(i).hasVideo){
			myComp.layer(i).enabled = false;
		}
	}
}catch(e){
}

 

Dodamfafa
DodamfafaAuthor
Participant
July 22, 2022

@Dan Ebberts 

Thank you, Dan.
var myLayer = myComp.layer("04.jpg");
Do not enter "04.JPG" directly in the syntax;
Is there a way to specify only the layer with the show icon on the left?

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
July 22, 2022

More like this then, maybe:

var myComp = app.project.activeItem;
var maxLayer = null;
for (var i = 1; i <= myComp.numLayers; i++){
	if (myComp.layer(i).hasVideo && myComp.layer(i).enabled){
		if (maxLayer == null){
			maxLayer = myComp.layer(i);
			continue;
		}
		if (myComp.layer(i).outPoint > maxLayer.outPoint){
			maxLayer = myComp.layer(i);
		}
	}
}
if (maxLayer != null){
	myComp.time = maxLayer.outPoint;
	myComp.workAreaStart = 0;
	myComp.workAreaDuration = maxLayer.outPoint;
}