Last updated July 28, 2026
This routine joins two separate polylines into one. You pick each of them near the ends you want joined, and it draws a connecting line between those two ends and then merges all three into a single polyline. The first one you pick sets the properties, so the result takes its layer, colour and linetype from that one.
It is by Axsys Technology Ltd, version 1.2, with a copyright range of 1990 to 1996 — the same house that wrote the distance and bearing labeller on this site, and it shows the same habits, good and bad.
It needs old-style polylines
This is the limitation that decides whether the routine is any use to you, so it comes first.
To find the two ends of a polyline, the routine steps through the polyline’s vertices as though each one were a separate object in the drawing. That is exactly how heavyweight polylines are built — a header followed by a string of vertex objects and a terminator. It is not how lightweight polylines work: an LWPOLYLINE holds all its vertices inside the one object, and stepping to the “next object” from it lands you on some unrelated entity elsewhere in the drawing.
AutoCAD has created lightweight polylines by default since Release 14, so on a current release, straight out of the box, this routine will not find the right endpoints. What it does instead is unpredictable, because it depends on whatever object happens to sit next in the drawing database.
If you want to use it, set the PLINETYPE system variable to 0 before drawing the polylines you intend to join, or convert existing ones to the old format. Otherwise, AutoCAD’s own PEDIT command has had a Join option for a very long time, and on modern geometry that is the tool to reach for.
What it does in practice
Where you click on each polyline is the whole of the control. The routine finds both ends of the polyline you picked, works out which one is nearer your pick point, and uses that end. Do the same on the second polyline and it has the two points to connect.
It then draws a line between those two points, collects the two polylines and the new line into one selection, and hands the lot to PEDIT’s Join option. The connecting line disappears into the merged polyline. If the ends already meet, the connecting line has zero length and the join is still made.
Closed polylines are refused outright. Pick one and the routine reports that the polyline is closed and stops, which is reasonable — a closed polyline has no free ends to join to.
One thing it does not do is put your command echo back. It switches echoing off when it starts and never restores it, so AutoCAD will be quieter than usual afterwards. Set CMDECHO back to 1 if that catches you out. It also leaves its working variables behind as globals rather than declaring them local.
Command reference
The file defines a single command, and the name is not obvious from the download: it is J2P, for join two polylines. The file is JOIN2.LSP and the archive is Join2.zip, but neither of those is the command.
How to load it
Join2.zip holds JOIN2.LSP and a short help file. Load the LSP with APPLOAD or add it to the Startup Suite. Our AutoLISP guide covers the options.
Step-by-step usage
- Make sure both objects are heavyweight polylines, as explained above.
- Type J2P. It prints its version banner.
- At “Select first POLYLINE to be joined:” click the first polyline near the end you want joined. This one determines the layer, colour and linetype of the result.
- At “Select POLYLINE to be joined to it:” click the second one, again near the end to be joined.
- The connecting line is drawn and the three objects are merged into one polyline.
Compatibility notes
Written between 1990 and 1996, so written-for rather than tested-on, and as covered above the polyline type it expects has not been AutoCAD’s default since Release 14. It is plain AutoLISP with no dialog boxes and no Express Tools calls, driving AutoCAD’s own LINE and PEDIT commands, so nothing in it requires the full product; LT users on LT 2024 or later, the release that brought AutoLISP to LT, face the same polyline-type limitation as everyone else. See what runs on AutoCAD LT. Because it modifies geometry, try it on a copy first.
Download
| Name: | Join 2 Polylines |
| Description: | Routine to join 2 polylines together. User is prompted to select 2 plines, which are joined by drawing a line between the ends closest to the pick point, then joining them with the PEDIT command. The first pline picked controls the layer, color, ltype, etc. |
| Type: | AutoCAD AutoLISP Routine |
| Author: | AXSYS |
| File Size: | 2 Kb |
| Cost: | Free |
| Worked on: | AutoCAD |
| Download File: | Join2.zip |
Related routines
- DISTBEAR — the same author’s line labelling routine.
- ZONE — measure the polyline once you have joined it up.
- ROUGHEN — another polyline editor, and a model of how to restore settings properly.