-
Search for a layer in comp
I’m trying to create a script that will search for a specific layer within a selected comp.
I want the script to work like a toggle basically, so if it finds an existing layer with the name “XYZ” I want it to delete this layer. Whereas if it doesn’t find a layer with this name, I want it to create a new layer with the name “XYZ”
I have managed to get the script working so it adds a layer, I just can’t find a way for it to search the comp and delete any existing ones.
Any suggestions would be so helpful!
var curSelection = app.project.activeItem;//check if selected layer is a comp
if (curSelection instanceof CompItem) {//run code here to create layer with name XYZ
} else if (//search comp for layer with name XYZ) {
//run code to remove layer}else
alert("this is not a comp!");