Check if layer exists with Diesel macro

Check if layer exists with Diesel macro

Anonymous
Not applicable
1,292 Views
3 Replies
Message 1 of 4

Check if layer exists with Diesel macro

Anonymous
Not applicable

Hello you all,

 

I made a macro where I change the layer names of files which I get from a 3rd party.

Since I always got the same file, there was no problem, but now I get files with other layernames.

 

So I want to write a DIESEL macro to check if a layer exists, and if so, change it's name, if not, then create one with the specific name.

 

Is it possible? I can't use LISP due to OEM restrictions. And I'm in 2013.

 

Or another way?

 

Thanks for your input!

 

Nicolaas

0 Likes
Accepted solutions (1)
1,293 Views
3 Replies
Replies (3)
Message 2 of 4

CodeDing
Advisor
Advisor

WITHOUT using lisp or a script, best I can think of is another macro:

- Always make the layer you're searching for (if it exists, it will not create duplicate)

- Then always rename that layer to what you want

Something like (untested)...

^C^C-layer m checklayer r checklayer newlayer  

..note there are 2 spaces after "newlayer"

Best,

~DD

0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@CodeDing wrote:

....

^C^C-layer m checklayer r checklayer newlayer  

....


 

If there are multiple Layers involved, I would recommend not the Make option but the New option.  You can give it multiple names with comma separators, all in the one option, and if a Layer already exists, it will likewise not make another, nor be bothered by the pre-existence of it.  It could also be faster, because it does not change the current Layer  in the process, as the Make option does, which is why Make can only take one Layer name at a time.  Then rename each one in turn.  [And you can make that final closing Enter visible  at the end, by using a semicolon instead of a second space.]

^C^C_.-layer _new old1,old2,old3,old4 _r old1 new1 _r old2 new2 _r old3 new3 _r old4 new4 ;
Kent Cooper, AIA
Message 4 of 4

Anonymous
Not applicable

Hello, sory for the late reply!

I just tested my macro with the _layer _new command and it works perfectly!

Thanks for the tip!

Nicolaas

0 Likes