Verify line ends are not free

Verify line ends are not free

keshishian1
Participant Participant
304 Views
8 Replies
Message 1 of 9

Verify line ends are not free

keshishian1
Participant
Participant

Hello,
I'm working on a LISP routine to verify that all lines in a drawing are properly connected to adjacent lines. Occasionally, the plans I receive contain very small gaps—often at square chamfers—which can cause issues. While the routine generally functions as expected, it sometimes flags lines that appear to be correctly connected. I'm wondering if this approach to checking connectivity is sound, or if there's a more reliable method I should consider. Any insights or suggestions would be greatly appreciated.

Thank You.

0 Likes
Accepted solutions (1)
305 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

 I see that it works perfectly fine with LINEs. That is what the lisp is written for. It does not support ARCs at all. All the red lines are connected to ARCs.

eekeeCZ_1-1756108572903.png

 

 

0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

 .... it works perfectly fine with LINEs. That is what the lisp is written for. It does not support ARCs at all. ....


If that's needed, these changes ought to work [untested] to also include Arcs, with a way of finding the start and end points of either object type, since that can't be done with entity data entries, because those points are not in the entity data for Arcs:

....

(vl-load-com)

(prompt "\nSelect Lines and Arcs to check for disconnected endpoints...")
(setq ss (ssget '((0 . "LINE,ARC"))))

....

;; Collect endpoints with entity handles
(setq i 0)
(while (< i (sslength ss))

(setq en (ssname ss i))
(setq ent (entget en))
(setq pt1 (vlax-curve-getStartPoint en))
(setq pt2 (vlax-curve-getEndPoint en))
(setq endpoints (cons (list pt1 pt2 en) endpoints))
(setq i (1+ i))
)

....

And the same could easily be expanded to include Polylines and Splines and Ellipses, but would need to be made more restrictive about those, to accept or process only those that are not closed.

Kent Cooper, AIA
0 Likes
Message 4 of 9

keshishian1
Participant
Participant

Thank You. I will add the code to my script.

0 Likes
Message 5 of 9

ronjonp
Mentor
Mentor

@keshishian1 

 

Here's another way to look for coincident end/start points. This will mark them with circles if not found.

(defun c:foo (/ a s)
  ;; RJP » 2025-08-25
  (cond
    ((setq s (ssget '((0 . "*LINE,ARC"))))
     (setq s (mapcar '(lambda (x) (list (vlax-curve-getstartpoint x) (vlax-curve-getendpoint x)))
		     (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	     )
     )
     (setq s (vl-sort (apply 'append s) '(lambda (r j) (< (car r) (car j)))))
     (while (cadr s)
       (setq a (car s))
       (setq s (cdr s))
       (if
	 (null (vl-some '(lambda (x) (and (equal a x 1e-4) (progn (setq s (vl-remove x s)) t))) s))
	  (entmakex (list '(0 . "CIRCLE") '(8 . "CHECK") (cons 10 a) '(40 . 4)))
       )
     )
    )
  )
  (princ)
)

 

 

 

0 Likes
Message 6 of 9

keshishian1
Participant
Participant

Thank You but it shows a few false positives.

keshishian1_0-1756156964901.png

 

0 Likes
Message 7 of 9

ronjonp
Mentor
Mentor

@keshishian1 Code updated above. Give it a try.

 

Strange though on your test drawing I don't get the result you're seeing.

ronjonp_1-1756158558222.png

 

 

0 Likes
Message 8 of 9

keshishian1
Participant
Participant

I tried and it gave the same result. It may be a variable setting that is causing this. It is fine: I can check those manually. thanks again.

0 Likes
Message 9 of 9

ronjonp
Mentor
Mentor

Sounds good ... glad to help! 🍻

0 Likes