Q) work area end expression or script

Community Beginner ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

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.

111.jpg

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.

222.jpg

 

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

TOPICS
Expressions , FAQ , Scripting

Views

83

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 21, 2022 Jul 21, 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;
}

Likes

Translate

Translate
Adobe Community Professional ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

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){
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

@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?

333.jpg

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

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;
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

LATEST

@Dan Ebberts 
Thank you, Dan!

This is the script I was looking for. I'll use it well.
Thanks once again.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines