More scripting fun... deleting a layer

What are the rules for layer deletion?

I’m using

-Layer _Delete grid

and getting:

Unable to delete layer

The are probably many. But the obvious one is if the layer is referenced by any objects, you don’t be able to delete it.

Thanks dale… but it’s not clear to me what that means exactly. I am able to delete it if I just click on the layer and hit delete.

It has objects and sublayers with objects but I want to just clear it all out with the script.

The layer UI is a ‘stronger.’ Can you post a file and let me know what layer you are trying to delete via command line scripting?