Skip to main content
Participant
September 10, 2021
Question

Grab the positioning of a layer inside a precomposed layer?

  • September 10, 2021
  • 5 replies
  • 273 views
I have a precomposed layer that contains many shapes. Inside my global comp, I have various positions being applied to the precomposed layer. Unfortunately, I need everything in my precomposed layer to go to the global comp due to lottie requirements. I am now looking for a way to grab each position of each layer inside this precomposed layer. How can I do that?

 

I have tried with this expression: comp("precomposedcomp").layer("precomposedcomplayer").transform.position

 

This expression works, but not the way I intended. It grabs the position of the layer inside the precomposed layer. The issue is that the positioning is set in the global comp... How could I possibly get this position? Assuming comps are exact same size.

This topic has been closed for replies.

5 replies

Community Expert
September 13, 2021

If you are trying to go generate code for an animation for a webpage then After Effects is your tool of last resort. It would never be my first choice because the app is designed to create video and any attempt to generate code from the animation is going to be a sledgehammer hack with a bunch of restrictions and bottlenecks. I would jump straight into Adobe Animate, a tool specifically designed to create code-based animations for the web. It will take a little creativity to get a 3D look to your artwork, but it can be done. Trying to get AE to generate the vector information required for a code-based animation is going to be impossible with the tools I am familiar with.

Mylenium
Legend
September 13, 2021

As far as I know SVGs cannot even have a 3D canvas, so what would this even achieve? Drop shadows and blurs can be just as well done using CSS properties and the rendering is unified, so it looks the same for SVG and HTML canvas. You may just have to manually insert the code. As for the code issues it would probably require to have the exact error messages. I'm pretty positive it should work, even though I'm a bit rusty on this stuff these days...

 

Mylenium

Mylenium
Legend
September 11, 2021

As Rick suggested, as a start you would need to use something like

 

wingL=comp("Plane").layer("Wing Left");

wingLPos=toComp.wingL(wingL.transform.anchorPoint);

 

After that you may need other layer space transforms to convert to whatever coordinates you need or you create your own math. Refer to this:

 

https://helpx.adobe.com/after-effects/using/expression-language-reference.html

 

Just be clear that none of this will magically turn your 3D layers into workable 2D layers for Lottie. You may need an awful lot of auxiliary constructs by ways of Nulls or referring to surface points on the plane's planes for specific stuff. That will inevitably also bloat the output file. In the end you may be better off just rendering an animated GIF...

 

Mylenium

Coll5E5AAuthor
Participant
September 12, 2021

Hello,

I tried your expression but believe you may have interpreted me wrong. I am also not the best at explaining this stuff, apologies. Lottie actually supports 3D under SVG and HTML. I can get it to work with precomposed under HTML settings, but I actually need SVG in order to do drop shadows and guassian blur. For some particular reason, Lottie with SVG does not handle 3D well when it's precomposed. For this reason, I'm trying to take it out of the precomposed layer and into the global comp. However, I do not believe toComp will be useful in this case since it appears to be based around grabbing 2D positioning from 3D positioning. I need something that will allow me to grab the exact same 3D positionings and put it to the global comp. Is this something possible? 

Thank you,

 

Coll5E5AAuthor
Participant
September 12, 2021

A quick follow up, I have done some reading up on toComp and toWorld. I believe what we are looking for is toWorld, however, this expression does not work:

 

wingL=comp("Plane").layer("Wing Left");

wingLPos=toWorld.wingL(wingL.transform.anchorPoint);

 

It appears wingLPos is causing the error, and I believe the error is originating from the expression starting with toWorld, however, I am not certain. Layer names and comp name is all correct. 

Community Expert
September 10, 2021

If you want the position relative to the main comp you need to use toWorld or toComp. 

 

A screenshot of your comp with the modified properties of the nested comp showing (press 'uu') and a screenshot of the flowchart of the main comp showing us which layer in the nested com (pre-comp) you want to grab the position from would help nail down the expression. 

Coll5E5AAuthor
Participant
September 10, 2021

Hi Rick, 

Thank you for the suggestion to use toWorld or toComp. I am not too familiar with these, but I have attached screenshots of the compositions. As you can see, "Plane" contains the contact plane, and then I edit this from the global comp. The global comp is where I can easily add positioning to it. However, now that I need to have everything in the global comp, this has become quite a headache. I am hoping I can find an expression or some type of solution to help out. 

OussK
Community Expert
Community Expert
September 10, 2021

using the composition is the correct way but it's not clear what is the issue exactly, can you post some screenshots so we can get a better idea

Coll5E5AAuthor
Participant
September 10, 2021

I have a precomposed 3D layer that has a position on it. I need to get the positioning of each layer but inside the precomposed layer, all the layers are the same position. That is because positioning is only being affected from global comp. How can I find out the individual positions are of each layer from the global comp?