• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

LayerMatch LISP: Set the Current Layer by Picking an Object

September 18, 2020

Last updated July 28, 2026

LayerMatch sets the current layer to match something you point at. Click any object and the layer it sits on becomes current — or type a layer name instead if you would rather. It is the small operation that sits behind half the layer fiddling in a working day: you are about to draw something that belongs with that, so make that layer current.

It is by Charles Alan Butler, version 1.0, dated 12 December 2005.

The listing has the wrong name on it

Worth clearing up before anything else. The download table below calls this “Line Then Text”, which is a different routine entirely — the name has been attached to the wrong entry at some point in the last twenty years. The description in the same table is correct.

What you get is LayerMatch. The file is layermatch.lsp, the command is LAYERMATCH, and it matches layers. Nothing in the download draws a line and then some text.

One prompt, two ways to answer

The clever part is the prompt, which accepts either a pick or typed text and works out which you gave it. Click an object and it reads that object’s layer; type a name and it uses that. One prompt, no mode switch, no second command for the typed case.

It also uses the nested form of object selection, which means it will read the layer of an object inside a block or an xref rather than reporting the layer the block sits on. That is usually what you want when you are pointing at something and thinking “that layer” — you mean the layer of the thing you can see, not its container.

The routine loops until it gets an answer it can use, so a miss re-prompts rather than dropping out and making you retype the command.

How it compares to what AutoCAD already has

Full AutoCAD has shipped a layer-matching command in Express Tools for many years, and current releases have layer tools built in. If you have those, you may not need this.

Where it earns its place is AutoCAD LT. Express Tools have never been part of LT, and LT did not gain AutoLISP at all until LT 2024 — so for LT users on 2024 or later this is a way to get the behaviour at all. It is plain AutoLISP with no dialog boxes, so there is nothing in it that LT cannot run.

Command reference

The file defines a single command, LAYERMATCH. That is a long name for something you will use constantly, so it is a good candidate for a two or three letter alias in your PGP file.

How to load it

Unzip Layermatch.zip and load layermatch.lsp with APPLOAD, or put it in the Startup Suite — a command this small only saves time if it is always there. No support files. Our AutoLISP guide covers loading.

Step-by-step usage

  1. Type LAYERMATCH.
  2. At “For layer select entity or enter layer name:” either click an object or type a layer name.
  3. That layer becomes current. Draw.

Remember that clicking something inside a block gives you the layer of that internal object, not the block’s own layer. If you want the block’s layer, click a block that sits on it in isolation, or type the name.

Compatibility notes

2005, which makes it one of the more recent routines in this library. It uses standard selection and entity functions that have not changed since, so it stands a good chance on a current release.

No dialog boxes and no Express Tools calls, so nothing requires the full product — see what runs on AutoCAD LT. It changes a setting rather than any geometry, so there is nothing at risk in trying it.

Download

Name: Line Then Text
Description: Match Layer Property, Select or enter layer name.
Type: AutoCAD AutoLISP Routine
Author: Charles Butler
File Size: 2 Kb
Cost: Free
Worked on: AutoCAD
Download File: Layermatch.zip

The Name row above is the mislabelling described at the top of this page. The download itself is LayerMatch.

Related routines

  • Delete Layer — the other end of layer housekeeping.
  • LLP Suite — a large set of layer commands with toolbars.
  • UPDBLOCK — fix the layers inside blocks.

References

  • AutoLISP: the complete guide
  • Free LISP routines library
  • AutoLISP on AutoCAD LT

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in