Page 1 of 1

Is there a function to remove a layer?

Posted: Fri May 27, 2022 5:38 pm
by jayh
A user submitted this question, and we wanted to share the process:
I can find removeAllLayers, is there a function to remove a specific layer?
Here is how you can accomplish this:
Assuming his displayed layer is referenced as "layer", for example:

layer = activeDisplay().createLayer('Image Display', data)

Then you can remove that individual layer with:

layer.doRemove()

He would just replace "layer" with whatever he called his layer at createDisplay().

If he isn't sure of the name of the layer, he could get a list of all layers in the display with:

layers = activeDisplay().getLayers()

And then remove individual layers by index number. For example, if he just has a map (index 0 in the list) and an image display (index 1 in the list) he could remove the image display layer with:

layers[1].doRemove()