Forums › Adobe After Effects Expressions › Scripting Layer Color
-
Scripting Layer Color
-
Ralph Moreau
June 17, 2022 at 2:07 pmI’ve looked all throughout the documentation, and google searches. Is there a way to script changing color of layers. I’m building a script that parents a null to another layer, then depending on that layers color, the null will be a specified color. Not looking for labels either, but color of an actual layer.
-
Dan Ebberts
June 17, 2022 at 6:49 pmThe only thing I can think of would be to do a replaceWithSolid() on the null’s source and specify the color you want, like this:
var myNull = app.project.activeItem.layer(1);
var myFootage = myNull.source;
myFootage.replaceWithSolid([1,0,0],myFootage.name,myFootage.width,myFootage.height,myFootage.pixelAspect);
-
Ralph Moreau
June 20, 2022 at 6:12 pmHi Dan,
Thank you! This is a very clever solution to changing the the color of the icon on the null layer. Which would be an amazing alternative. But if possible is there a way to actually change color of the layers themselves on the timeline?
-
Dan Ebberts
June 20, 2022 at 9:50 pmI think you do have to go after the color of the solidsource for the null (rather than the color of the layer itself), but it’s not as tricky as I thought. This should work:
var myNull = app.project.activeItem.layer(1);
myNull.source.mainSource.color = [1,1,0];
-
Filip Vandueren
June 21, 2022 at 9:08 amI think what you need is to change the color of the layer in the timeline is to just set the label:
app.project.activeItem.layer(index).label = 8; // takes an integer from 0-16 - 0=no label
You can choose one of the preset color-labels as setup in your preferences, but you cannot change those presets via scripting.
-
Ralph Moreau
June 21, 2022 at 12:53 pmThank you both for your brilliant solutions, this definitely places me at the end of the creating the script. For some reason I thought the label method, only applied to layer markers. Both these methods make it a lot more efficient in creating color hierarchies.
Log in to reply.