Skip to content

beastt1992/WallCenterline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

中文版 | English


WallCenterline.lsp — AutoCAD Automatic Wall Centerline Generator

Select a wall layer. Let the algorithm find every centerline.


The Problem

Generating wall centerlines in AutoCAD is one of those tasks that sounds simple — but becomes a nightmare at scale:

  • Manually offsetting every wall to find the center
  • Walls of different thicknesses on the same floor plan
  • T-junctions, L-corners, and cross intersections all need individual trimming
  • Plan changed? Every centerline is now wrong.

The old workflow: OFFSET one side, calculate half the wall thickness, trim at every corner, repeat 200 times per floor. Miss one and your structural calculation is off.


The Solution

WallCenterline scans your entire floor plan in one pass and automatically generates a clean, trimmed centerline network for every wall — regardless of thickness variation, corner type, or drawing imperfections.

  • Single Layer Input: Just pick any line on the wall layer. Done.
  • Multi-Thickness Support: Automatically handles walls of different thicknesses on the same plan (set your min/max range).
  • Smart Corner Closing: T-junctions, L-corners, and cross intersections are all automatically extended and trimmed to meet perfectly.
  • Drawing Imperfection Tolerance: Handles slightly non-parallel lines, misaligned endpoints, and minor drafting errors that are common in real-world drawings.

How It Works

WallCenterline doesn't just offset lines. It uses a multi-stage geometric inference engine:

  1. Nearest Valid Neighbor Pairing: For each wall line, the algorithm finds its closest valid parallel counterpart within the defined wall thickness range — skipping door frames, window sills, and other noise inside the wall cavity.
  2. 7-Universe Ensemble Voting: The same geometry is processed under 7 different tolerance configurations simultaneously. A centerline is only accepted if it survives at least 3 independent parameter sets — filtering out false positives while preserving every real wall.
  3. Geometric Intersection Closing (AutoExtendTrim): After voting, the algorithm directly computes the intersection point between each pair of perpendicular centerlines and snaps endpoints to exact intersection geometry — no approximation.
  4. True Cluster Mean Axis: All parallel projections are grouped into clusters. The final axis position is computed as a true arithmetic mean of all members — not a rolling average — making results completely independent of line input order or drawing rotation.

Installation

  1. Download WallCenterline.lsp
  2. In AutoCAD, type APPLOAD
  3. Load the file
  4. Type WCL to run

Tip: Add to AutoCAD's Startup Suite (Contents) for automatic loading every session.


Usage

Type WCL and follow the prompts. The tool features Global Memory for wall thickness settings.

  1. Click any line on your wall layer to identify it.
  2. Box-select the area you want to process.
  3. Done — the centerlines are drawn on a new WALL-CENTER layer automatically.

To adjust wall thickness range: Type S at the first prompt to enter Settings mode and update your min/max wall thickness values.


Commands

Command Description
WCL Run the wall centerline generator

Settings

Parameter Default Description
Min Wall Thickness 10 Minimum distance between two wall faces to be recognized as a wall pair
Max Wall Thickness 30 Maximum distance. Pairs farther apart than this are ignored

Note: Units follow your current AutoCAD drawing units. For metric drawings in centimeters, 10–30 means 10cm–30cm walls.


Notes

Feature Details
Global Memory Remembers min/max wall thickness across your AutoCAD session.
WALL-CENTER Layer All centerlines are drawn on a dedicated WALL-CENTER layer (Color 1 / Red) created automatically.
Drawing Tolerance Handles endpoints misaligned up to ~25% of minimum wall thickness, and lines that are slightly non-parallel (up to 20% angular deviation).
No Polyline Required Works with both LINE and LWPOLYLINE entities.

Compatibility

Version Status
AutoCAD 2014+ ✅ Supported

Troubleshooting

Extra centerlines appeared where there are no walls? Check that your wall layer is clean — stray lines, dimension lines, or hatch boundaries on the same layer will be processed as walls. Move non-wall geometry to a separate layer before running.

Some walls are missing their centerlines? Make sure your Min/Max wall thickness range covers all wall types in the drawing. Type S to open Settings and widen the range. Also check that the two faces of the wall have sufficient overlap length — very short stub walls may need the range adjusted.

Corner not closing properly? This usually happens when two centerlines are slightly misaligned due to drawing imperfections. Running WCL a second time on the same result will typically resolve remaining open corners.

Results differ when the drawing is rotated? This is resolved in v53+. The algorithm uses true cluster mean averaging that is mathematically independent of input order and drawing orientation.


Version History

Version Notes
v65 AutoExtendTrim Bug Fix: Corrected 3-argument max call — corner intersection geometry now computed accurately.
v64 7-Universe Ensemble Voting: Multi-parameter consensus system filters false positives while preserving all real walls.
v61 Two-Stage Corner Pass (3a/3b): V lines extend first, then H lines snap to the extended V — eliminates residual open corners.
v58 Nearest Valid Neighbor Projection: Skips door frames and cavity noise; only pairs true wall faces.
v53 True Cluster Mean: Axis averaging changed from rolling mean to full sum/count — results now rotation-invariant.
v51 Absolute Spatial Sorting: Deterministic sort order eliminates handle-order randomness.

License

MIT License — Free to use, modify, and distribute.


Made with ❤️ for Architectural Drafters & Engineers.

About

AutoLISP tool that automatically generates wall centerlines from 2D architectural floor plans in AutoCAD. Handles T/L/cross junctions, variable wall thickness, and drawing imperfections.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors