MIDL LISP: Create Centre Line Between Two Edges (Free AutoLISP Download)
MIDL computes a genuine centerline between two selected edge polylines (for example, the two surveyed edges of a road) by sampling both curves at matching parametric positions and connecting the midpoints. Unlike the native OFFSET command, this works correctly even when the two edges are not perfectly parallel along their length.
MIDALIGN-bgol (Create Centre Line Between Two Edges)
Command Type: AutoLISP routine (works in AutoCAD, BricsCAD, ZWCAD and most AutoLISP-compatible CAD platforms)
Developed by: BGol Community, bgol.in
Inspired by the general concept of edge-to-centerline derivation utilities used in CAD/survey drafting. This is an original, independently written routine, new file name, new command name, new source code, created so the CAD community has a free, editable, open-source alternative.
Overview
MIDL computes a genuine centerline between two selected edge polylines (for example, the two surveyed edges of a road) by sampling both curves at matching parametric positions and connecting the midpoints. Unlike the native OFFSET command, this works correctly even when the two edges are not perfectly parallel along their length.
How to Use
- Load
MIDALIGN-bgol.lspinto your CAD session (drag-and-drop the file onto the drawing window, or use theAPPLOADcommand). - Type
MIDLat the command line and press Enter. - Select the first edge polyline.
- Select the second edge polyline.
- A new centerline polyline is drawn between the two edges on a dedicated layer,
BGOL-MIDL(colour yellow). The original edge polylines are left untouched.
Why Use It
- Accurate on non-parallel edges, produces a geometrically correct centerline even where corridor width varies, something
OFFSETcannot do. - Saves manual construction, no need to hand-place and average points along a long, irregular alignment.
- Ready for further design, directly usable as the reference alignment for chainage marking, curve design, or cross-sections.
Where to Use It
- Deriving a road, channel, or corridor centerline from two surveyed edge lines, especially where the width varies.
- Preparing an alignment polyline for further design work (e.g. feeding into a chainage-marking or curve-design routine).
- Any land-survey or road-design task requiring a true geometric centerline between two boundary lines.
Notes
- Sampling density defaults to 24 midpoints; edit the
*bgol-midl-samples*constant near the top of the .lsp file for a smoother result on highly irregular edges. - Both edges are sampled at matching normalized parametric positions (0 to 1 along each curve), so the pairing stays sensible even if the two edges have a different number of original vertices.
- Works on LWPOLYLINE, LINE and ARC edges (or a mix), since it samples using the ActiveX curve interface rather than raw vertex lists.
- Source code is fully open, feel free to study, modify, and redistribute it under the same open, free-for-all spirit.
Credits
Developed and shared for the CAD community by BGol Community. Website: https://bgol.in/ Free and open-source, use it, modify it, share it, for personal or commercial work alike.
Frequently Asked Questions
MIDL is a standard AutoLISP routine, so it runs in AutoCAD, BricsCAD, ZWCAD, and most other AutoLISP-compatible CAD platforms without modification.
Sampling density defaults to 24 midpoints; edit the *bgol-midl-samples* constant near the top of the .lsp file for a smoother result on highly irregular edges.
Accurate on non-parallel edges, produces a geometrically correct centerline even where corridor width varies, something OFFSET cannot do.
Yes. MIDL is fully open-source and free to use, modify, and redistribute for both personal and commercial work, developed and shared by the BGol Community.
Drag and drop MIDALIGN-bgol.lsp onto your open drawing window, or load it through the APPLOAD command, then type MIDL at the command line to run it.
๐ค About BGol Community
BGol Community of Advanced Surveying builds and shares free, open-source tools for the survey and CAD drafting community.
๐ Made with โค๏ธ by BGol Community of Advanced Surveying
Free, open-source, and built for the CAD community, for personal or commercial use, always.