Last updated July 28, 2026
This resets the contents of your block definitions to BYLAYER, so blocks stop carrying hard-coded colours and start taking their appearance from the layer you insert them on. It is the fix for a drawing where every symbol comes in red no matter what layer it lands on.
Sensibly, it skips xrefs and xref-dependent blocks. Those belong to another drawing and editing their definitions in yours would achieve nothing useful.
There is no command to type
Deal with this first, because it is the whole difficulty with the download.
An AutoLISP file makes something available as a typed command by defining it with a C: prefix on the name. This file does not do that anywhere. It defines its work as an ordinary function called LAYERFIX, which means loading the file gives you nothing at the command line — type LAYERFIX and AutoCAD will tell you it is an unknown command.
What you have to do instead is call it as a function, by typing it with brackets around it:
(layerfix)
That works and is how the author presumably used it — probably called from another routine or a menu macro rather than typed. If you would rather have a proper command, add one line to the end of the file:
(defun c:layerfix () (layerfix))
The file’s own header calls it Layerfix.LSP, while the download is named after the BYLAYER job it does — so the two names you might expect to type are both wrong, and the real answer is the third one.
Why BYLAYER matters
Worth stating for anyone who has inherited a drawing and not met this problem before.
When a block is built, the objects inside it can either carry their own explicit colour or be set to BYLAYER. If they carry their own, the block looks the same wherever you put it — which sounds convenient and is the opposite of what you want, because it means your layer scheme has no effect on it. Plot styles keyed to colour stop working, layer-based control stops working, and turning something a different colour means editing every block.
Setting the contents to BYLAYER hands control back to the layer. Insert the block on a layer and it looks like that layer. That is how a block library should behave.
Note that this changes the block definitions, so every insertion of an affected block changes at once. That is the point, and it is also the reason to work on a copy.
How to load it
Unzip Bylaybk.zip and load the .lsp file with APPLOAD, then call it as described above. No support files. Our AutoLISP guide covers loading.
Step-by-step usage
- Work on a copy. This edits block definitions and affects every insertion.
- Load the file with APPLOAD.
- Type
(layerfix)at the command line, brackets included, or add the wrapper line above and type LAYERFIX. - Regenerate, then check a few blocks on different layers to confirm they now follow the layer colour.
If a block still comes in with its own colour after running this, check whether it is an xref-dependent block — those are deliberately skipped.
Compatibility notes
No date or author in the file. It works by walking block definitions and editing entity data directly, which is the durable approach and has not changed.
Plain AutoLISP with no dialog boxes and no Express Tools calls, so nothing requires the full product; LT users on LT 2024 or later, the release that brought AutoLISP to LT, should be able to run it. See what runs on AutoCAD LT.
If you want the same job with a proper command and a choice of colour, UPDBLOCK does it as two commands you can type.
Download
| Name: | Block to Bylayer |
| Description: | Changes the block definitions to BYLAYER . Will skip all XREF & XREF dependent blocks. |
| Type: | AutoCAD AutoLISP Routine |
| Author: | Anon |
| File Size: | 2 Kb |
| Cost: | Free |
| Worked on: | AutoCAD |
| Download File: | Bylaybk.zip |
Related routines
- UPDBLOCK — the same job as two typed commands, layer and colour separately.
- Fixblock — another block maintenance routine.
- Block Count Report — find out what blocks you have before fixing them.