 ; Join - make a number of entities into a polyline.
 ; Copyright 1994, 1999 by Rocket Software
 ; It is not possible for an organization with more than three members to
 ; accomplish anything which makes any sense.
 (DEFUN C:JOIN (/ ss nogo typ enam entt closd)
  (setvar "cmdecho" 0)
  (command "undo" "m")
  (write-line "Select entities to join: ")
  (setq ss (ssget))
  (if ss
     (progn
 ; Now search the ss for a line, an arc, or an open polyline.
          (setq nogo T)
          (while (and (< 0 (sslength ss)) nogo)
                (setq typ (cdr (assoc 0 (setq entt 
                                         (entget (setq enam (ssname ss 0)))))))
                (setq closd (cdr (assoc 70 entt)))
                (cond ((= typ "LINE")
                       (setq nogo ()))
                      ((= typ "ARC")
                       (setq nogo ()))
                      ((or (= typ "POLYLINE") (= typ "LWPOLYLINE"))
                       (if (= (logand closd 1) 1)    ; closed polyline?
                           (ssdel enam ss)
                           (setq nogo ())))
                      (T
                       (ssdel enam ss))))
 ; If there are any entities left in the ss:
          (if (< 0 (sslength ss))
              (if (or (= typ "POLYLINE") (= typ "LWPOLYLINE"))
                  (command "pedit" enam "j" ss "" "")
                  (command "pedit" enam "y" "j" ss "" "")))))
 (princ))