@Dan-Rod wrote:
.... would it be possible for me to add the .csv extraction to the codes? ....
Something like this?
(defun C:TEST (/ liness file n ldata ptlist thispt thisss blk)
(if (setq liness (ssget "_X" '((0 . "LINE")))); add Layer filter if desired
(progn ; then
(setq file (open "C:/TEMP/TEST.CSV" "w")); <--EDIT file path/name
(repeat (setq n (sslength liness)); make list of all Line endpoints
(setq
ldata (entget (ssname liness (setq n (1- n))))
ptlist (cons (cdr (assoc 10 ldata)) ptlist); add start point
ptlist (cons (cdr (assoc 11 ldata)) ptlist); add end point
); setq
); repeat
(while ptlist
(setq
thispt (car ptlist); first remaining
thisss (ssget "_C" (polar thispt (/ pi 4) 2) (polar thispt (* pi 1.25) 2) '((0 . "LINE,INSERT")))
;; 2 argument based on sample drawing AS CORRECTED, to find Block as well as Lines if present
); setq
(if
(and
(not (ssget "_P" '((0 . "INSERT") (2 . "3R,4R")))); not already a Block there
(> (sslength thisss) 2); more than 2 Lines meet there
); and
(progn ; then
(command "_.insert" (setq blk (if (= (sslength thisss) 3) "3R" "4R")) "_non" thispt "" "" "")
(write-line (strcat blk "," (rtos (car thispt)) "," (rtos (cadr thispt)) "," (rtos (caddr thispt))) file)
); progn
); if
(setq ptlist (vl-remove thispt ptlist)); remove all same point from list
;; will not remove if not exactly meeting; some may remain in list,
;; which is why above checks whether already a Block there
); while
(close file)
); progn
); if
(prin1)
)
Follow the EDIT instruction. In the corrected sample drawing, it made a .CSV file that looks like this in Excel:

and like this in Notepad:
3R,864.7452,135.122,0
3R,798.5671,135.122,0
4R,717.1359,135.122,0
4R,466.1691,135.122,0
3R,350.0266,135.122,0
It could be made to put a header line in labeling those columns as Block Name, X coordinate, Y coordinate, Z coordinate. Or the Z could be omitted if it will always be 0. You can mess around in other ways with exactly what information you want included.
Kent Cooper, AIA