View Full Version : Renaming Layers Using a Macro
DB007
23rd Aug 2011, 01:38 pm
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;laye r3;AA_layer3;R;layer4;AA_layer4;lo;AA*;;erase;all; ;-layer;u;*;;-purge;all;*;n;zoom;e;
BIGAL
24th Aug 2011, 08:10 am
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.
BlackBox
24th Aug 2011, 11:32 am
Consider the LAYTRANS (http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-4a76.htm,topicNumber=d0e258234) command. :wink:
DB007
24th Aug 2011, 01:08 pm
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 (http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-4a76.htm,topicNumber=d0e258234) command. :wink:
Thanks to both but neither will work as I really need it to run on LT too.
DNK
24th Aug 2011, 01:18 pm
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;laye r3;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.
DB007
24th Aug 2011, 01:40 pm
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.
DNK
24th Aug 2011, 01:47 pm
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.
DB007
24th Aug 2011, 01:56 pm
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.
DNK
24th Aug 2011, 01:59 pm
No worries.
BlackBox
24th Aug 2011, 02:05 pm
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:
DB007
24th Aug 2011, 02:12 pm
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.
BlackBox
24th Aug 2011, 02:19 pm
Weird; thanks for the clarification.
BIGAL
25th Aug 2011, 03:43 am
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
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.