Okay, this is quite an obscure one..
AFAIK when you create a new art object, you can only define the document that it will be put into.
It is automatically created in the first layer in the document, even if you want it to be in another layer.
So I use the append function to move it over.
The thing is, that when the first layer is locked, it produces an error.
With the following sample code, I have the first layer locked and the second layer selected:
It could be nice if we were able to make new Art objects like:
But like I said, it's obscure - and maybe I'm wrong!