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

Expression question - check for an effect on a layer above

Community Expert ,
Aug 02, 2020 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.

TOPICS
Expressions , Scripting

Views

181

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

Community Expert , Aug 02, 2020 Aug 02, 2020

This should work:

 

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

 

Dan

Votes

Translate

Translate
Community Expert ,
Aug 02, 2020 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

Votes

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

Copy link to clipboard

Copied

LATEST

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

 

 

Votes

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