How do I check to see if a layer exists in the layer table, and if not add it.
Why bother? The Add method _doesn't_ cause an error if the Layer object already exists. -- R. Robert Bell How do I check to see if a layer exists in the layer table, and if not add it.
You know, I almost answered with a nearly identical response. In most of my own code I used to use the Add method and be done with it. However, it has been suggested that that is a bad habit to get into, since most other collections will puke on the Add method if the item already exists. So I have been forcing myself to ALWAYS allow for an error being raised by the Add method, even when I know it won't. Who knows, maybe Adesk will "fix" the layers collection to act like all other collections in the future. Just my casual coder $0.01....
In two years we'll all be coding in C# and forget about all this anyway, right?! ;^) -- R. Robert Bell You know, I almost answered with a nearly identical response. In most of my own code I used to use the Add method and be done with it. However, it has been suggested that that is a bad habit to get into, since most other collections will puke on the Add method if the item already exists. So I have been forcing myself to ALWAYS allow for an error being raised by the Add method, even when I know it won't. Who knows, maybe Adesk will "fix" the layers collection to act like all other collections in the future. Just my casual coder $0.01....
No. But I was including the slugs. -- R. Robert Bell Do you really think it's going to take you that long to learn it?