Jump to content

Renaming Layers Using a Macro


Recommended Posts

We get drawings regularly with many layers and only need about 25% of them, I created a Macro which renames the ones we want and locks them so I can do a select all and delete without losing the layers i want. unlock them, purge and zoom extents.

 

This works perfectly except for some of the drawings we get have an extra layer. When the Macro searches for this layer if its not there it goes into a loop. Is it possible to check if the layer exists 1st before running the rename command?

 

Is this possible without LISP/VBA?

 

Thanks

 

example of the macro:-

 


^C^C-layer;r;layer1;AA_layer1;r;layer2;AA_layer2;r;layer3;AA_layer3;R;layer4;AA_layer4;lo;AA*;;erase;all;;-layer;u;*;;-purge;all;*;n;zoom;e;

Link to comment
Share on other sites

I would write a lisp etc and probably have it read a TXt file with the layer names in it makes it easier to add or subtract or even use different layer combos.

Link to comment
Share on other sites

I would write a lisp etc and probably have it read a TXt file with the layer names in it makes it easier to add or subtract or even use different layer combos.

 

Consider the LAYTRANS command. :wink:

 

Thanks to both but neither will work as I really need it to run on LT too.

Link to comment
Share on other sites

We get drawings regularly with many layers and only need about 25% of them, I created a Macro which renames the ones we want and locks them so I can do a select all and delete without losing the layers i want. unlock them, purge and zoom extents.

 

This works perfectly except for some of the drawings we get have an extra layer. When the Macro searches for this layer if its not there it goes into a loop. Is it possible to check if the layer exists 1st before running the rename command?

 

Is this possible without LISP/VBA?

 

Thanks

 

example of the macro:-

 


^C^C-layer;r;layer1;AA_layer1;r;layer2;AA_layer2;r;layer3;AA_layer3;R;layer4;AA_layer4;lo;AA*;;erase;all;;-layer;u;*;;-purge;all;*;n;zoom;e;

 

How about creating a second macro that deals specifically with this layer? You could run that first, if the layer's not there, then esc and run this one.

Link to comment
Share on other sites

I've done that already but was hoping to make it a little cleaner and save the moans about having to run two macros every time. (Even though a quick look at the drawing would make it obvious which macro to use.)

 

Would it be worth looking into Diesel? I know very little about it.

Link to comment
Share on other sites

Keeping it in the macro form, add the layer at the beginning of the macro, then it will always be there when you go to manipulate it later.

 

Yes! It Works Perfect! Thank you.

Link to comment
Share on other sites

Thanks to both but neither will work as I really need it to run on LT too.

 

Admittedly, I do not use LT. Would you be kind enough to explain to me how using an AutoCAD command will not work for both versions (Full & LT)? :unsure:

Link to comment
Share on other sites

Admittedly, I do not use LT. Would you be kind enough to explain to me how using an AutoCAD command will not work for both versions (Full & LT)? :unsure:

 

LAYTRANS is an unknown command in LT and there is nothing in the help either. So im guessing it was removed from LT?

 

Thanks for the input though.

Link to comment
Share on other sites

You can create a txt file and copy and paste to the command line advantage here is easy to edit use notepad

 

sorry not tested you use a space as an enter so end of lines may have spaces not seen or else just do new blank line

 

-la N layer1
r layer1 ;AA_layer1
r layer2 AA_layer2
r layer3 AA_layer3
R layer4 AA_layer4
lo AA*  erase all 
-layer u *  
-purge all * n 
zoom e

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...