• 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

UPDBLOCK LISP: Change Layer or Colour Inside AutoCAD Blocks

September 19, 2020

Last updated July 28, 2026

You have inherited a drawing full of blocks whose contents were drawn on named layers in explicit colours. Every time you insert one it ignores the layer you put it on and appears in whatever colour it was built with. The correct fix is to have the block’s contents on layer 0 with colour BYLAYER, so the block takes on the properties of wherever you insert it — but doing that means exploding, changing, reblocking, and redefining, for every block.

These two routines do it without exploding anything. They reach into the block definition itself, change the layer or colour of every entity inside it, and update the drawing. Every insertion of that block updates at once, because the definition is what changed.

They are by Caren Lindsey, the layer one dated June 1993 and the colour one July 1996.

The two commands

  • UPDBLKLY — sets every entity in the selected blocks to one layer that you name. If the layer does not exist it offers to create it. Colours are left alone.
  • UPDBLKCL — sets every entity in the selected blocks to one colour number. Layers are left alone. It shows a colour number table on screen if you ask for it or type something out of range.

Worth being precise here, because the bundled description reads as though the layer routine also changes colours to BYLAYER. It does not. Reading the code, UPDBLKLY touches the layer and nothing else; colour is the other routine’s job. To get the usual result — contents on layer 0, colour BYLAYER — run UPDBLKLY with layer 0, then UPDBLKCL with colour 256, which is the number for BYLAYER.

The colour table the routine prints is a useful reminder of the two special numbers: 0 is BYBLOCK, 256 is BYLAYER, and 1 to 255 are the ordinary colours.

This changes the block definition

The author puts this in the file in capitals, and it deserves repeating. You select one insertion, but every insertion of that block in the drawing changes, because the block definition is what gets edited. That is the entire point — it is what makes the routine worth having — but it means a stray pick has drawing-wide consequences.

Two things follow. Work on a copy the first time, and regenerate afterwards so you are looking at the updated definitions rather than a stale display. And note that it steps through the entities in the block definition directly, so a nested block inside your block is treated as a single entity: its own contents are not visited. For nested blocks, run the command again picking the nested one.

Both routines install an error handler that restores the previous one if you cancel, so a Ctrl-C partway through leaves your session tidy — though it does not undo the entities already changed. There is no undo grouping, so putting a half-finished run back means several presses of U.

How to load it

Updblock.zip contains the two files, UPDBLKLY.LSP and Updblkcl.lsp. Load whichever you need with APPLOAD, or both. There are no support files. Our AutoLISP guide covers loading.

Step-by-step usage

  1. Work on a copy of the drawing.
  2. Type UPDBLKLY. At “Enter new layer name:” type the layer — usually 0. If it does not exist you are asked whether to create it.
  3. At “Pick blocks to update.” select one or more block insertions. Only insertions are accepted; anything else in your selection is filtered out.
  4. Then type UPDBLKCL and enter 256 for BYLAYER at the colour prompt, and select the same blocks.
  5. Regenerate. Every insertion of those blocks now follows the layer it sits on.

Compatibility notes

Dated 1993 and 1996, so written-for rather than tested-on. They work by reading and modifying entity data directly, which is long-standing practice that has not changed, and they drive no commands other than LAYER, so there is a reasonable chance they still behave on a current release — but test on a copy before trusting them with a library.

Plain AutoLISP with no dialog boxes and no Express Tools calls, so nothing in them requires the full product; LT users on LT 2024 or later, the release that brought AutoLISP to LT, should be able to run them. See what runs on AutoCAD LT.

Download

Name: UPDBlock
Description: This file contains 2 block updating lisps;
Updblkly.lsp – This routine allows the user to update the layer of all entities
within a block to a single layer (exam: layer=0) without the user having to
explode the symbol. By default the color of all entities are changed to
BYLAYER. The routine changes the original definition of the block
within the current drawing.
Updblkcl.lsp – This routine allows the user to update the color of all entities
within a block to a single color (exam: color=BYLAYER) without the user
having to explode the symbol. By default the layer name of all entities are
NOT changed. The routine changes the original definition of the block
within the current drawing.
Type: AutoCAD AutoLISP Routine
Author: Caren Lindsey
File Size: 4 Kb
Cost: Free
Worked on: AutoCAD
Download File: Updblock.zip

Related routines

  • Fixblock — another block maintenance routine.
  • Auto Block Rename — bring block names into line with a standard.
  • WBLKALL — export the cleaned-up blocks to a library folder.

References

  • AutoLISP: the complete guide
  • Free LISP routines library
  • AutoLISP Lesson 9: Data Structures
  • 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