& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
Hello guys and greetings from germany,
I don't know anything about creating LISPs for AutoCAD - but I'm looking for some to change the current layer (after executing a command) to a specific one and then swicht back to the current.
I need this for the following commands:
Current layer = 0 - command "_mtext" with layer = text - switch layer back to current layer after executing the command
Current layer = 0 - command "_text" with layer = text - switch layer back to current layer after executing the command
Current layer = 0 - command "_mleader" with layer = mleader - switch layer back to current layer after executing the command
Current layer = 0 - command "_insert" with layer = block - switch layer back to current layer after executing the command
I already know how to do this with the tool palette - but I don't want to work with it, cause I'm using the toolbars.
Hope you guys can help me!
Thank you for your help in advance!
Solved! Go to Solution.
Like Kent's answer keeping it simple you could do like B1, B2, so draw a certain beam 1 on layer1, Beam2 on layer2.
The other way in more complicated code is using a simple (setvar 'clayer "Beam2") before drawing objects. So the beam has objects on different layers.
As suggested also check does layer exist. So use a small global defun.
(defun chklay (lay COL LT / )
(if (= (tblsearch "layers" lay) nil)
(command "-layer" "M" lay "C" col "" "LT" lt "" "")
(setvar 'clayer lay)
)
(princ)
)
(chklay "Beam2" 1 "Continuous")
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name