How to rename solids, precomps and other layer objects?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
Hausgross
Posts: 5
Joined: December 8th, 2010, 3:44 am
Location: Saarbrücken, Saarland, Germany
Contact:

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
Haus&Gross communications GmbH
Homepage - Motionblog - Twitter
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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;
User avatar
Hausgross
Posts: 5
Joined: December 8th, 2010, 3:44 am
Location: Saarbrücken, Saarland, Germany
Contact:

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.
Haus&Gross communications GmbH
Homepage - Motionblog - Twitter
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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";
			}
		}
	}
}
User avatar
Hausgross
Posts: 5
Joined: December 8th, 2010, 3:44 am
Location: Saarbrücken, Saarland, Germany
Contact:

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:
Haus&Gross communications GmbH
Homepage - Motionblog - Twitter
Post Reply