If you work with parcels, floor plans, or site boundaries in AutoCAD, you probably know how tedious it can be to combine two adjacent or overlapping polygons into one single boundary. Usually, you have to trim overlapping lines, explode shapes, and use
PEDIT or BOUNDARY to clean things up manually.
Today, I’m sharing a lightweight, free AutoLISP routine (MERGEPOLY) that automates this entire process in seconds. With just one command, you can select two or more touching or overlapping closed polylines and merge them into a single, clean closed polyline.
How the LISP Routine Works
Behind the scenes, this script automates a classic 4-step AutoCAD geometry trick:
- Converts your selected closed polylines into Regions.
- Uses the UNION command to fuse them into one single shape.
- Explodes the resulting region back into individual lines and arcs.
- Uses PEDIT to join the outer perimeter back into a single closed polyline.
The AutoLISP Code (MERGEPOLY.lsp)
Click Download .LSP to save the file directly to your computer, or click Copy Code to paste it into Notepad:
How to Load and Run the LISP in AutoCAD
Follow these quick steps to use the routine in your drawing:
- Download or Save the File: Click the Download .LSP button above to save
MERGEPOLY.lspdirectly, or copy the code into Notepad and save it asMERGEPOLY.lsp(with Save as type set to All Files (*.*)). - Load into AutoCAD: Open your AutoCAD drawing, type
APPLOADin the command line, and press Enter. - Select the Script: Browse to where you saved
MERGEPOLY.lsp, select it, and click Load (then click Close). (Tip: Add it to your Startup Suite in the APPLOAD window if you want it available in every drawing automatically). - Run the Command: Type
MERGEPOLYin the command line and press Enter. - Select Polygons: Click the polygons you want to combine and press Enter. Your shapes are now merged into one!
Troubleshooting & Tips for Best Results
- Polygons Must Be Closed: If one of your polylines has a tiny gap, AutoCAD won't convert it to a Region. Select your polyline, open the Properties palette (
CTRL+1), and verify that Closed is set to Yes. - Same Elevation (Z-Value): Both polygons must lie flat on the exact same plane. If the command fails on 3D or imported survey drawings, select your objects and run the
FLATTENcommand first. - Must Touch or Overlap: Make sure the polygons share an edge or overlap. If there is empty space between them, they cannot form a single continuous boundary.
Have a question about this routine or need a custom AutoLISP script for your workflow? Leave a comment below!


No comments:
Post a Comment