Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Q) work area end expression or script

Community Beginner ,
Jul 21, 2022 Jul 21, 2022

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
386
Translate
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

Community Expert , 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;
}
Translate
Community Expert ,
Jul 21, 2022 Jul 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){
}

 

Translate
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

@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

Translate
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 Expert ,
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;
}
Translate
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
LATEST

@Dan Ebberts 
Thank you, Dan!

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

Translate
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