AutoCAD layer is a great feature to manage objects in your drawings. What we don’t like about it is we often need to change layer before we draw. For example when we want to draw dimensions, we need to change the layer to dimension layer. Then change the layer again when we need to draw other objects.

You can create a macro command to do this automatically. Of course, you can use LISP. But the good thing about macro is you can use it in AutoCAD LT too.

AutoCAD macro command

The command macro

If you are not familiar with AutoCAD command macro, you can read this excellent tutorial by Paul Munford.

The macro code for this macro is very simple:

^C^C-layer;set;DIMENSIONLAYERNAME; _DIMLINEAR

Replace DIMENSIONLAYERNAME with your dimension layer. This layer must exist in your drawing for this macro to works.

Using the macro

There are various ways how you can use the macro. The easiest way is to place it in tool palettes as described in this tutorial.

If you are familiar with AutoCAD CUI, you can place the command in a ribbon tab or toolbar. You can also use it as a shortcut. For example ctrl+D to activate this macro.

A more advanced macro

Programming code abstract screen of software developer.

The macro above will work great. We can make the macro to change the layer back to the previous layer immediately after the command is finished. So when you are working with wall layer, create a dimension on dimension layer, then the current layer is back to wall layer.

The macro will be:

^C^C-layer;set;DIMENSIONLAYERNAME; _DIMLINEAR;\\\LAYERP

This macro will allow you to create dimension on dimension layer. Then change the layer back to previous. However, if you press Esc key before the dimension is drawn, the layer previous command won’t be executed.

Saved from: http://www.cad-notes.com/change-layer-for-autocad-command-macro/?utm_source=CADnotes+newsletter&utm_campaign=6035dadc04-MC_all_articles_campaign&utm_medium=email&utm_term=0_65d9e5bbfa-6035dadc04-65078729&mc_cid=6035dadc04&mc_eid=f686bd6917

Advertisements