Dear mat20,
Copy and paste the below expessions in a file and svae it
as a text file named: MP.LSP
you can load this file into AutoCAD using the command
APPLOAD. After loading this file you will have new
command named MP. This command prompts to select an object
(line, arc, or polyline) and joins all coincident objects
to it.
(defun c:mp(/ e)
(setq e (entsel "\n Select a line, arc, or 2D pline: "

)
(if (or (= (cdr (assoc 0 (entget (car e)))) "LINE"

(= (cdr (assoc 0 (entget (car e)))) "ARC"

)
(command "._PEDIT" e "Y" "J" "all" "" ""

(if (= (cdr (assoc 0 (entget (car e)))) "LWPOLYLINE"

(command "._PEDIT" e "J" "all" "" ""

)
)
(princ)
)
Regards,
Farzad