Page 1 of 1

How to rename solids, precomps and other layer objects?

Posted: December 9th, 2010, 1:55 am
by Hausgross
Hi to all AEnhancers!

I'm quite new to AE scripting though I wrote some simple scripts for common tasks.

I know how to rename "normal" layers like text layers or some footage, but I don't know how to rename precomposed compositions or solids. I have the same problem when I want to turn e.g. a precomp layer into a 3D layer. My solution only works for text and footage layers..

It would be really helpful if someone could provide me a sample code showing how to do this :D

Re: How to rename solids, precomps and other layer objects?

Posted: December 9th, 2010, 3:43 am
by Paul Tuersley
Here's an example which should hopefully help:

Code: Select all

{
	var activeItem = app.project.activeItem;
	var theLayer;
    
	if (activeItem != null && activeItem instanceof CompItem) {
        
		for (x = 1; x <= activeItem.numLayers; x++) {
			
			theLayer = activeItem.layer(x);
			
			if (theLayer.source != null) {
				theLayer.source.name += " X";
			} else {
				theLayer.name += " Y";
			}
		}
	}
}
          
You can rename a solid or precomp layer in the comp in the same way as other layers, without changing the source name, but then you'd only see the change if you toggled the name column to show "Layer Name" instead of "Source Name"

To make any layer (that can be made) a 3D layer you should just need this, regardless of layer type:

Code: Select all

theLayer.threeDLayer = true;

Re: How to rename solids, precomps and other layer objects?

Posted: December 9th, 2010, 4:10 am
by Hausgross
Thank you Paul :mrgreen:

Now I'm able to rename solids and precomps if their original name hasn't been changed.
If they are manually renamed neither my nor your script seem to work.

Edit:
Paul Tuersley wrote:To make any layer (that can be made) a 3D layer you should just need this, regardless of layer type:

Code: Select all

theLayer.threeDLayer = true;
I tried it and it works perfectly for e.g. text layers, pictures or other footage, but not for precomps and solids.

Re: How to rename solids, precomps and other layer objects?

Posted: December 9th, 2010, 4:24 am
by Paul Tuersley
The layer name thing is about whether you are viewing "Layer Name" or "Source Name". Toggle the column heading in the Timeline to switch between them. I imagine just changing the layer.name will rename user name changes, so you can always rename layer.name and layer.source.name to cover both.

I can't explain why the 3D thing isn't working as it works ok for me. Maybe you could post your code?

Code: Select all

{
	var activeItem = app.project.activeItem;
	var theLayer;
    
	if (activeItem != null && activeItem instanceof CompItem) {
        
		for (x = 1; x <= activeItem.numLayers; x++) {
         
			theLayer = activeItem.layer(x);
			theLayer.threeDLayer = true;
         
			if (theLayer.source != null) {
				theLayer.source.name = "TEST";
				theLayer.name = "TEST";
			} else {
				theLayer.name = "TEST";
			}
		}
	}
}

Re: How to rename solids, precomps and other layer objects?

Posted: December 9th, 2010, 7:10 am
by Hausgross
Hi Paul,

thanks for your efforts - your explanation really helped me fixing problems in my script. I didn't know there are two kinds of names for layers...

Turning precomps into 3D layers didn't work for me because of a mistake I made :lol: