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

Is there an AE expression to make a shape layer size match a comp layer size...

Enthusiast ,
Aug 26, 2024 Aug 26, 2024

I have a 2D map of Europe that I pre-composed into a 3D composition with a null-parented camera. 

In my 3D composition, I'm adding the Sea as a background 3D layer. 

Is there an expression I can use that would make the Sea layer size match the Pre-Comp layer Map size, so I don't have to do this manually?

I'm essentially trying to crop the Sea layer to the Map layer. Just wondering if there's an expression for that. 

 

Thank you in advance.

 

EUROPE 3D MAPEUROPE 3D MAP

 

   

TOPICS
How to
1.3K
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

Advocate , Aug 26, 2024 Aug 26, 2024

Try to take inspiration from this:
you need to parent the SEA layer to the EUROPE layer.


You can adjust the transformations of the EUROPE layer
or even change the size of the EUROPE composition,
and the SEA layer should follow.

 

screenshot.png

 

Translate
Advocate ,
Aug 26, 2024 Aug 26, 2024

Try to take inspiration from this:
you need to parent the SEA layer to the EUROPE layer.


You can adjust the transformations of the EUROPE layer
or even change the size of the EUROPE composition,
and the SEA layer should follow.

 

screenshot.png

 

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
Enthusiast ,
Aug 27, 2024 Aug 27, 2024
LATEST

Hi Airweb, thank you very much for solving my issue. After parenting the Sea layer to the Europe map composition in the 3D scene, the sea layer's size now perfectly matches the map's scale with this single expression that you kindly provided: 

var sr = parent.sourceRectAtTime(); var sf = parent.scale / 100; [sr.width * sf[0], sr.height * sf[1]]

It turns out that I didn't have to bother with pasting the other two expressions for the Position and Scale properties of the Sea Layer. But thanks all the same. Thank you again so much for your help! 😀  

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 ,
Aug 26, 2024 Aug 26, 2024

This expression applied to the Size parameter of a Rectangle Path of a Shape Layer will set the X and Y values to the Compsition width and height.

 

 

// Get the width and height of the composition
compWidth = thisComp.width; compHeight = thisComp.height;
// Return the composition size as an array
[compWidth, compHeight]

 

 

 

 

WarrenHeaton_0-1724732596298.png

 

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
Advocate ,
Aug 26, 2024 Aug 26, 2024

It works if he places his SEA layer within his EUROPE composition, that would indeed be simpler.

But apparently, he wants his layer to be outside of the EUROPE composition.
So the active composition size doesn't matter, we can exclude thisComp.width/height from the solution.

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
Enthusiast ,
Aug 26, 2024 Aug 26, 2024

Hi Airweb and Warren. Thank you both very much for your help. Sorry, I forgot to mention that my reason for placing the Sea layer outside of my Europe comp has to do with how it affects layers and masking. If I place the Sea in my Europe comp, it intereferes with my layers. I took a pdf map of Europe from Wikipedia and removed the map's blue sea background with AE's Extract FX. This is so that I can draw layers over countries and not have to worry about spilling my layers over the coastlines. But if I then introduce a Sea layer as a background, it kills the Extract effect on the land layer. So instead I add my Sea layer in the 3D comp. In the example below, you can see my Sea layer enabled and then disabled in the original comp. 

 

Screenshot 2024-08-27 at 2.58.22 AM.pngScreenshot 2024-08-27 at 2.58.31 AM.png 

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
Enthusiast ,
Aug 27, 2024 Aug 27, 2024

Applying the Extract effect on the Wikipedia pdf map to remove the original blue background:

 

Screenshot 2024-08-27 at 3.00.57 AM.png

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