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

[Script] Check if a layer is visible.

New Here ,
Jan 15, 2021 Jan 15, 2021

Is there a way to tell if the pixels of a layer are visible in a specific time?

Things like .width or .sourceRectAtTime will give the original dimensions of a layer, even if the opacity/scale is set to 0. But how to mesure what's actually visible in the screen?

 

I found sampleImage(), which might do the trick, but I honestly have no idea how to make it work, even after reading the documentation.

 

Thanks!

TOPICS
Scripting
567
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
Mentor ,
Jan 15, 2021 Jan 15, 2021

You can use opacity and scale to determan if a layer will theoretically be visible or not (if opacity > 0 and scale !=0 = layer visible). But this is not bullet proof, since a layer can also be not visbile due to countless effects and layer modes.

 

sampleImage() might be a better approach, but it kind of feels like you'll need to check every pixel in your comp and compare its value with the pixels of the layer. Tricky!

 

What is your use case?

 

*Martin

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 ,
Jan 16, 2021 Jan 16, 2021

sourceRect gives you the size in layer space. So you need to convert the 4 corners to comp space taking into account the layer transforms and all the potential parenting. Unfortunately, scripting in contrast to expressions does not hav toComp transforms built-in. So there is not really an easy way to do that. Either you implement the transforms yourself, or you create a hack, where you create a layer with an expression to do the transform you need, read the result from the expression and delete the layer again.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
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 ,
Jan 29, 2021 Jan 29, 2021
LATEST

sampleImage() is an expression function, are you building a script or an expression? And are you using transparent footage that may or may not be visible at certain points, or do you just want to check if a layer has opacity / the visibility toggle on?

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