Nikon Posted January 30 Posted January 30 (edited) It is necessary to join several segments or polylines lying on the same straight line in pairs. But this code only works with lines. Is it possible for this to work with polylines as well? LINE, LWPOLYLINE, POLYLINE (defun c:JoinPairs ( / ent1 ent2 ) (princ "\nSelect the first line or press Enter/ESC to finish.") (while (setq ent1 (car (entsel "\nFirst line for JOIN: "))) (setq ent2 (car (entsel "\nSecond line for JOIN: "))) (if ent2 (command "_.JOIN" ent1 ent2 "") (progn (prompt "\nThe second line is not selected. Exit.") (exit) ) ) ) (princ "\nJoin Pairs command is completed.") (princ) ) Edited January 31 by Nikon Quote
GLAVCVS Posted January 30 Posted January 30 (edited) Hi Nikon If you explode a lwpolyline you will have a line. So you just have to break it up and delete the original. Simply replace '(command "_.JOIN" ent1 ent2 "")' with the code I have attached (progn (if (= (cdr (assoc 0 (entget ent1))) "LWPOLYLINE") (setq ent (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-explode (vlax-ename->vla-object ent1)))))) x (vla-delete (vlax-ename->vla-object ent1)) ent1 ent ) ) (if (= (cdr (assoc 0 (entget ent2))) "LWPOLYLINE") (setq ent (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-explode (vlax-ename->vla-object ent2)))))) x (vla-delete (vlax-ename->vla-object ent2)) ent2 ent ) ) (command "_.JOIN" ent1 ent2 "") ) Edited January 30 by GLAVCVS 1 Quote
Nikon Posted January 30 Author Posted January 30 (edited) On 1/30/2025 at 8:07 PM, GLAVCVS said: If you explode a lwpolyline you will have a line. So you just have to break it up and delete the original. Simply replace '(command "_.JOIN" ent1 ent2 "")' with the code I have attached Yes, this is a great option! Thank you very much! (defun c:JoinPairsGL ( / ent1 ent2 ) (princ "\nSelect the first line or press Enter/ESC to finish.") (while (setq ent1 (car (entsel "\nFirst line for JOIN: "))) (setq ent2 (car (entsel "\nSecond line for JOIN: "))) (if ent2 ; (command "_.JOIN" ent1 ent2 "") (progn (if (= (cdr (assoc 0 (entget ent1))) "LWPOLYLINE") (setq ent (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-explode (vlax-ename->vla-object ent1)))))) x (vla-delete (vlax-ename->vla-object ent1)) ent1 ent ) ) (if (= (cdr (assoc 0 (entget ent2))) "LWPOLYLINE") (setq ent (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-explode (vlax-ename->vla-object ent2)))))) x (vla-delete (vlax-ename->vla-object ent2)) ent2 ent ) ) (command "_.JOIN" ent1 ent2 "") ) (progn (prompt "\nThe second line is not selected. Exit.") (exit) ) ) ) (princ "\nJoin Pairs command is completed.") (princ) ) Edited January 30 by Nikon Quote
BIGAL Posted January 31 Posted January 31 I think this was asked recently else where, I used JOIN which works for lines. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.