I have selected all text from drawing to sort by Y axis. It gives some strange output that is some texts are on same Y axis but they sorted differently. I don't understand any logical reason.
Any help will be highly appreciated.
For your ready reference screenshot and drawing attached.
(setq ipassocvfd (ssget "_w" '(8.02218 21.63036) '(34.03070 0.86320) '((0 . "text,mtext") (1 . "IP*"))))
(repeat (setq il (sslength ipassocvfd))
(setq fele (ssname ipassocvfd (setq il (1- il))))
(setq Mcoord (cdr (assoc 11 (entget fele ))))
(setq Mtag (cdr (assoc 1 (entget fele ))))
(setq ipdata (cons fele ipdata))
(setq ipdata (cons Mtag ipdata))
(setq ipdata (cons (cadr Mcoord) ipdata))
(setq ipdata (cons (car Mcoord) ipdata))
(setq masterlist (cons ipdata masterlist))
(setq ipdata '())
)
(setq im (length masterlist))
(setq masterlist1 masterlist)
(while (/= masterlist nil)
(setq y1 (cadr (setq motn (car masterlist))))
(setq listtosearchY (mapcar '(lambda (sublist) (nth 1 sublist)) masterlist))
(repeat (length listtosearchY)
(setq pos (vl-position y1 listtosearchY))
(if (/= pos nil)
(progn
(setq listtosearchY (LM:RemoveNth pos listtosearchY))
(setq Yax (cons (nth pos masterlist) Yax))
(setq masterlist (LM:RemoveNth pos masterlist))
))
)
(if (/= Yax nil) (progn (setq sortedlist (cons Yax sortedlist))))
(setq Yax nil)
)
(defun LM:RemoveNth ( n l / i )
(setq i -1)
(vl-remove-if '(lambda ( x ) (= (setq i (1+ i)) n)) l)
)
;;;