Ever found yourself looking at a note, a room label, or a component description on your drawing and thinking: "I need to make a layer named exactly that"?
The standard way to do this is tedious:
- Open the Layer Properties Manager.
- Click "New Layer".
- Carefully type out the name (or try to copy-paste it from the text).
- Assign a color.
- Close the manager, select your text, and manually change its layer.
What if you could do all of that in one single click?
In this post, we’re sharing a powerful AutoLISP routine (
TCL) that automates the entire process. It extracts text string content, builds a brand-new layer, gives it a unique color, sets it as current, and immediately moves your selected text onto it!What Does This AutoLISP Script Do?
- Smart Extraction: Selects any
TEXTorMTEXTobject and safely strips out messy MText formatting codes. - Instant Creation: Checks if the layer exists. If it doesn't, it creates it instantly.
- Auto-Coloring: Automatically generates a random, highly visible AutoCAD Color Index (ACI) for new layers, intelligently avoiding grays or whites that blend into your background.
- Auto-Move: Instantly moves your selected text object onto the newly created layer.
- Sets Current: Sets the layer as active (
CLAYER) so you can keep drawing right away.
How to Load and Use This Script in AutoCAD
- Save the File: Paste the code into Notepad and save it as
TextToCurrentLayer.lsp. Make sure the extension is.lspand not.txt. - Load into AutoCAD: Type
APPLOADin your AutoCAD command line, hit Enter, find your file, and click Load. - Run the Shortcut: Type
TCL(short for Text to Current Layer) and press Enter. - Select Your Text: Click on any text string on your screen.
Boom! Your layer is built, colorized, active, and your text is perfectly organized.
autocad lisp layer from text, make layer from text lisp, autolisp layer creator, convert text to layer autocad.

No comments:
Post a Comment