Skip to main content
Participant
August 17, 2022
Answered

If/Else, Stop Expression if no Parent

  • August 17, 2022
  • 1 reply
  • 331 views

Is it possible to use an if/else statement to ignore an expression and use its "value" if it doesn't have a parent layer?

 

I'm attempting to build a template that utilizes multiple text layers where, if a checkbox is enabled, then that text layer will automatically adjust positioning based on other text layers in the layer stack. I have it setup to look at several variables like the text box height of other text layers or its own layer, font sizes, and any additional values controlled by sliders. At the moment, all of these text layers are parented to a null layer to establish the starting position. On rare occasions, I might want to remove a text layer from that layer stack so that I can manually position it. It would also be nice to supress the expression error since it wouldn't have a parent layer.

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

Like this, I think:

if (hasParent){
 // your expression here
}else{
  value
}

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 17, 2022

Like this, I think:

if (hasParent){
 // your expression here
}else{
  value
}
Participant
August 17, 2022

Wow, definitely was overthinking that one. Thank you Dan!