Highlighted

Expression question - check for an effect on a layer above

Adobe Community Professional ,
Aug 02, 2020

Copy link to clipboard

Copied

I have searched high and wide and can't seem to find an answer. Maybe I'm just tired. I need to check to see if there is a slider with a specific name on the layer above the current layer and then return a default value if the slider does not exist. I thought this approach would work, but it throws an error.

 

if(thisComp.layer(index - 1).effect("Line Spacing")("Slider") == null)
	lineGap = 0
else
	lineGap = thisComp.layer(index - 1).effect("Line Spacing")("Slider");

 

There must be a way to check to see if there is an effect added to another layer.  If I add a slider named Line Spacing to the layer above and change the == from null to 100 then the conditional statement works, the lineGap matches the slider value until it reaches 100 then drops to zero.

 

If anyone knows the answer it's Dan_Ebberts. I hope I'm missing something simple.

This should work:

 

try{
lineGap = thisComp.layer(index - 1).effect("Line Spacing")("Slider");
}catch(e){
lineGap = 0;
}

 

Dan

Topics

Expressions, Scripting

Views

37

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

Expression question - check for an effect on a layer above

Adobe Community Professional ,
Aug 02, 2020

Copy link to clipboard

Copied

I have searched high and wide and can't seem to find an answer. Maybe I'm just tired. I need to check to see if there is a slider with a specific name on the layer above the current layer and then return a default value if the slider does not exist. I thought this approach would work, but it throws an error.

 

if(thisComp.layer(index - 1).effect("Line Spacing")("Slider") == null)
	lineGap = 0
else
	lineGap = thisComp.layer(index - 1).effect("Line Spacing")("Slider");

 

There must be a way to check to see if there is an effect added to another layer.  If I add a slider named Line Spacing to the layer above and change the == from null to 100 then the conditional statement works, the lineGap matches the slider value until it reaches 100 then drops to zero.

 

If anyone knows the answer it's Dan_Ebberts. I hope I'm missing something simple.

This should work:

 

try{
lineGap = thisComp.layer(index - 1).effect("Line Spacing")("Slider");
}catch(e){
lineGap = 0;
}

 

Dan

Topics

Expressions, Scripting

Views

38

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
Guide ,
Aug 02, 2020

Copy link to clipboard

Copied

This should work:

 

try{
lineGap = thisComp.layer(index - 1).effect("Line Spacing")("Slider");
}catch(e){
lineGap = 0;
}

 

Dan

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
Reply
Loading...
Adobe Community Professional ,
Aug 02, 2020

Copy link to clipboard

Copied

Perfect Dan. Thanks. It's now in my expression bible...

 

 

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
Reply
Loading...