perform multiple JOIN commands at once on unrelated lines

perform multiple JOIN commands at once on unrelated lines

Gh_man
Advocate Advocate
3,761 Views
12 Replies
Message 1 of 13

perform multiple JOIN commands at once on unrelated lines

Gh_man
Advocate
Advocate

Is there a way to perform multiple JOIN commands at once on unrelated lines? For example, if I had a series of 5 lines that had been cut in half using a trim command as such:

| | | | |

| | | | |

... I could re-connect them with a JOIN command, but I'd have to do so with 5 separate commands. Is there a way to do them as a batch in a single command?

0 Likes
Accepted solutions (1)
3,762 Views
12 Replies
Replies (12)
Message 2 of 13

Patchy
Mentor
Mentor
0 Likes
Message 3 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

not sure to understand the question, but if you start command _JOIN simply select all 10 lines (e.g. using window selection) ... doesn't that work for you?

Why the need of calling _JOIN 5 times?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 4 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this routine. Learn how to use LISP HERE

 

(defun c:JoinMultiple (/ ss i a ang lst ent)

  (if (setq ss (ssget "_:L" '((0 . "LINE"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i)))
            ang (angle (cdr (assoc 10 (entget ent))) (cdr (assoc 11 (entget ent))))
            ang (rtos (- ang (if (>= ang pi) pi 0.)) 2 6)
            lst (if (setq a (assoc ang lst))
                  (subst (cons ang (cons ent (cdr a)))
                         a
                         lst)
                  (cons (list ang ent) lst)))))
  (foreach l (mapcar 'cdr lst)
    (while (> (length l) 1)
      (setq e (car l)
            l (cdr l))
      (repeat (setq i (length l))
        (command "_.JOIN" e (nth (setq i (1- i)) l) ""))))
  (princ)
 )
Message 5 of 13

Patchy
Mentor
Mentor

Join command only let you pick 1 source

Untitled.png

0 Likes
Message 6 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> Join command only let you pick 1 source

I can use window selection and take all objects with one selection

 

20190214_202436.png

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 13

Gh_man
Advocate
Advocate

Thank you , that lisp does exactly what I needed!

 

, "MULTIPLE" does speed up the process by saving a right-click, but I'd like to window-select all lines in a single go.
 
, I'm quite curious how you made that work? When my selection set includes even one line that is not co-linear with the others, I get an error message and nothing happens. Ie., in my example at the top, I would get the message: "0 objects joined, 10 objects discarded from the operation". The only way I can make it work is to do each line individually.
0 Likes
Message 8 of 13

Patchy
Mentor
Mentor

Hi Alfred,

Doesn't work for me (probably mine is 11 y.o. autocad ☺)

0 Likes
Message 9 of 13

ВeekeeCZ
Consultant
Consultant

@Alfred.NESWADBA , see the file. The result of JOIN command depends on whether all lines (or even arcs!) are in one direction and behind each other or not. The routine collects all lines by angles, then joins them.

 

0 Likes
Message 10 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

this is my result:

 

 

But running further tests ... the difference is that my objects are touching end-point to start-point, and that's why it's working on my side, my sample.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 11 of 13

Gh_man
Advocate
Advocate

Something interesting about the "ends touching" method: the end result is a series of polylines, not lines, even though both methods use the join command. Not sure why it was programmed that way?

0 Likes
Message 12 of 13

Kent1Cooper
Consultant
Consultant

@Alfred.NESWADBA wrote:

....

>> Join command only let you pick 1 source

I can use window selection and take all objects with one selection

....


 

I'm wondering, too, how you do that, or at least what conditions you're starting with....  I can do that if they're touching at their ends, though if I'm starting with Line entities, it makes them into two-line-segment collinear Polylines, with a vertex at the point where they met, not into just overall-length Lines as Joining them separately does.  If there are gaps  broken out of them as in earlier images, I get the same 0-joined messages.  [Acad2019]

Kent Cooper, AIA
0 Likes
Message 13 of 13

ВeekeeCZ
Consultant
Consultant

Yes, I know. The JOIN command give vary outcomes depending on mutually position and way of selection. And I wouldn't say it's expected behavior. Why aren't the line in your case connected in single lines but the polylines instead? Why in my case are 2 breaked and separated lines connected into one line?! It does not make much of sense.

Fortunately the OP has what he wanted and the case is closed.

 

0 Likes