1 person found this helpful
The function is called remove() for both graphics and layers. (Presumable because "delete" is already taken.)
Please bear with me, I am trying to understand how this works.
So how would you code that if I am trying to delete the layer that was created when the document was first created. How do I identify a layer when I didn't create it? I know that it's name will be 'Layer 1' so how can I use that to delete that layer.
On a similar note, I wouldn't have to delete the layer if I could just rename it, but I still have the problem of identifying a layer I didn't create. This has been a difficult concept for me to understand, and I have read through the documentation a couple of times.
Any help would be great.
app.activeDocument.layers.item("Layer 1") returns a pointer to any named item (similar to "swatches.item("Red")", fonts.item("Arial"), etc.).
Perhaps it is easiest to save a reference to your layer when creating it:
myLayer = app.activeDocument.layers.add();
myLayer.name = "I will be removed shortly";
myLayer.layerColor = UIColors.GOLD;
myLayer.visible = false; // hides it
myLayer.locked = true; // locks it
.. more stuff here ..
myLayer.remove(); // gets rid of it