wahoo! It's the weekend and so CAD is going to sleep.
Going to leave this one here for now though it doesn't complete your problem, it is a stepping stone till next time.
Running this LISP, select a single line and it will grab all the lines connected to it and return this as a selection set.
Just to remind me for later, the next steps here are:
- Split the output of this up into 'long lines' and each segmented arc - the segmented arcs can then run the above codes
- Repeat this over a full drawing
Part way there.
(defun c:ConnectedLines ( / MySS MyList MyLines acount pt pt1 pt2 pt3 pt4)
(setq MyEnt (car (entsel "Select a line"))) ; A selected line
(setq ConnectedLines (ssadd MyEnt)) ; List for lines connected to selected
(setq MyList (ssadd MyEnt)) ; List for used lines ; Later: for selection set selections
(setq Pt (cdr (assoc 10 (entget MyEnt)))) ; End A point
(setq AnEnt MyEnt) ; Starting Entity
(repeat 2 ; Repeat2 - both directions
(setq StopLoop "No") ; Marker to stop looping
(while (= StopLoop "No")
(setq Pt1 (mapcar '+ '(-0.0001 -0.0001) Pt)); Small area around end of line
(setq Pt3 (mapcar '+ '( 0.0001 0.0001) Pt)); Other corner
(setq MySS (ssget "_C" Pt1 Pt3 '((0 . "LINE"))) ) ; select joining lines within 0.0001
(if (= (sslength MySS) 2) ; If only 2 joining lines
(progn
(setq MySS (ssdel AnEnt MySS)) ; Next line
(setq AnEnt (ssname MySS 0)) ; next line entity name
(setq APtA (cdr (assoc 10 (entget AnEnt)))) ; next line end points
(setq APtB (cdr (assoc 11 (entget AnEnt))))
(if (ssmemb AnEnt MyList)
(progn
(princ "Repeating Selection")
(setq StopLoop "Yes")
)
(progn
(setq MyList (ssadd MyEnt)) ; List for used lines ; Later: for selection set selections
(setq ConnectedLines (ssadd AnEnt ConnectedLines)) ; add next line to list of connected lines
(if (equal APtA Pt 0.0001)
(setq Pt APtB)(setq Pt APtA) ; work out if next line connected at end A or B
)
)
)
) ; end progn
(progn
(setq StopLoop "Yes")
) ; end progn
) ; end if SSlength = 2
) ; end while stoploop
(setq Pt (cdr (assoc 11 (entget MyEnt))))
(setq AnEnt MyEnt)
) ; end repeat
(princ "\n")(princ (sslength ConnectedLines))(princ " Connected Lines Found")
ConnectedLines ; Return Connected Lines
)