I have a lisp which writes the coordinates of selected lines in a notepad file. The problem happens when I want to select many lines I simply select all of them by window crossing selection on screen. But when those points are written in notepad they are not sequential. If I start selecting lines from bottom to top by drag selection they should be written from bottom top order. This lisp works if I select each line individually. I have also attached my drawing for reference.
This is the lisp.
(defun c:TesT (/ fileName selectionset)
;;; Tharwat 04. Dec. 2011 ;;;
(if (and (setq fileName (getfiled "Name of File >>..." "" "txt" 1))
(setq selectionset (ssget '((0 . "LINE"))))
)
(progn (setq filename (open filename "w"))
((lambda (i / namess entlist pt1 pt2)
(while (setq namess (ssname selectionset (setq i (1+ i))))
(setq entlist (entget namess))
(setq pt1 (cdr (assoc 10 entlist)))
(setq pt2 (cdr (assoc 11 entlist)))
(write-line (strcat (rtos (car pt1) 2) "\t" (rtos (cadr pt1) 2) "\t" (rtos (caddr pt1) 2)) fileName)
(write-line (strcat (rtos (car pt2) 2) "\t" (rtos (cadr pt2) 2) "\t" (rtos (caddr pt2) 2)) fileName)
)
)
-1
)
(close fileName)
)
(princ)
)
(princ)
)