- (defun c:tt (/ box e i ss )
- (defun ebox (e / pa pb)
- (Vlax-Invoke-Method
- (Vlax-Ename->Vla-Object e)
- 'GetBoundingBox
- 'pa
- 'pb
- )
- (setq pa (trans (vlax-safearray->list pa) 0 1)
- pb (trans (vlax-safearray->list pb) 0 1)
- )
- (list pa pb)
- )
- (setq thisdrawing (vla-get-activedocument
- (vlax-get-acad-object)))
- (vla-startundomark thisdrawing)
- (setq ss (ssget '((0 . "INSERT")))
- boxlst nil
- FUZZ 0;;;;坐标误差,相差这么大被认为是一行
- )
- (repeat (setq i (sslength ss))
- (setq e (ssname ss (setq i (1- i)))
- box (ebox e)
- boxlst (cons box boxlst)
- )
- )
- (setq
- boxlst (vl-sort
- boxlst
- (function (lambda (e1 e2)
- (if (equal (cadr (car e1)) (cadr (car e2))FUZZ)
- (< (car (car e1)) (car (car e2)))
- (> (cadr (car e1)) (cadr (car e2)))
- )
- )
- )
- )
- )
- ;;; (setq i 1)
- (foreach box boxlst
- (vl-cmdf "rectang" (car box) (cadr box))
- ;;; (Make-TEXT (car box) (rtos i 2 0) 0.11)
- ;;; (SETQ I(1+ I))
-
- )
- (vla-endundomark thisdrawing)
-
- )
- (defun Make-TEXT (pt str Textheigh)
- (entmakeX
- (list '(0 . "TEXT") (cons 1 str) (cons 10 pt) (cons 40 Textheigh))
- )
- )
左右优先,上下其次,fuzz用于上下坐标误差内还认为是同一行 |