Search This Blog

Streamline Your AutoCAD Workflow: AutoLISP to Create Layers Directly from Text

 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:
  1. Open the Layer Properties Manager.
  2. Click "New Layer".
  3. Carefully type out the name (or try to copy-paste it from the text).
  4. Assign a color.
  5. 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 TEXT or MTEXT object 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
  1. Save the File: Paste the code into Notepad and save it as TextToCurrentLayer.lsp. Make sure the extension is .lsp and not .txt.
  2. Load into AutoCAD: Type APPLOAD in your AutoCAD command line, hit Enter, find your file, and click Load.
  3. Run the Shortcut: Type TCL (short for Text to Current Layer) and press Enter.
  4. 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