I have a series of python scripts that edit layers and move objects between layers. At random, apparently, I’ll get this error:
I’m using Worksessions with my document as well as linked blocks, but this particular script does nothing but insert layers. Also, it will work for hours happily with worksessions, then it will do this. Restarting the document fixes this.
It happens on several scripts wherever LayerNames() is called.
def LayerNames(sort=False): ""Return names of all layers in the document. Parameters: sort [opt] = return a sorted list of the layer names Returns list of strings """ rc =  for layer in scriptcontext.doc.Layers: if not layer.IsDeleted: rc.append(layer.FullPath) if sort: rc.sort() return rc
the error is on the line
if not layer.IsDeleted: rc.append(layer.FullPath)
Here is the (hacky) script itself: