(defun C:TBX(/ al-selectonscreen gettextbox myobj objcoll ptlst tmp)
(defun al-selectonscreen(lst / dxflst filter_code filter_value newset ssets thisdrawing)
(vl-load-com)
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list ssets "SS1")))
(setq newSet (vla-add ssets "SS1"))
(progn
(vla-delete (vla-item ssets "SS1"))
(setq newSet (vla-add ssets "SS1"))
)
)
(setq dxflst (list (mapcar 'car lst) (mapcar 'cdr lst)))
(setq filter_code (vlax-make-safearray vlax-vbinteger (cons 0 (- (length (car dxflst)) 1))))
(setq filter_value (vlax-make-safearray vlax-vbvariant (cons 0 (- (length (cadr dxflst)) 1))))
(vlax-safearray-fill filter_code (car dxflst))
(vlax-safearray-fill filter_value (cadr dxflst))
(vla-selectOnScreen newSet filter_code filter_value)
newSet
)
(defun getTextBox (en / b enx h j l n o r w)
(cond
((= 'VLA-OBJECT (type en)) (setq enx (entget (vlax-vla-object->ename en))))
((= 'ename (type en)) (setq enx (entget en)))
((= 'list (type en)) (setq enx en))
)
(setq l
(cond
((= "TEXT" (cdr (assoc 0 enx)))
(setq
b (cdr (assoc 10 enx))
r (cdr (assoc 50 enx))
l (textbox enx)
n (cdr (assoc 210 enx))
)
(list
(list (caar l) (cadar l))
(list (caadr l) (cadar l))
(list (caadr l) (cadadr l))
(list (caar l) (cadadr l))
)
)
((= "MTEXT" (cdr (assoc 0 enx)))
(setq
n (cdr (assoc 210 enx))
b (trans (cdr (assoc 10 enx)) 0 n)
r (angle '(0.0 0.0 0.0) (trans (cdr (assoc 11 enx)) 0 n))
w (cdr (assoc 42 enx))
h (cdr (assoc 43 enx))
j (cdr (assoc 71 enx))
o (list
(cond
((member j '(2 5 8)) (/ w -2.0))
((member j '(3 6 9)) (- w))
(0.0)
)
(cond
((member j '(1 2 3)) (- h))
((member j '(4 5 6)) (/ h -2.0))
(0.0)
)
)
)
(list
(list (car o) (cadr o))
(list (+ (car o) w) (cadr o))
(list (+ (car o) w) (+ (cadr o) h))
(list (car o) (+ (cadr o) h))
)
)
)
)
(setq l
(
(lambda (m)
(mapcar
'(lambda (p)
(mapcar '+(mapcar '(lambda (r) (apply '+ (mapcar '* r p))) m) b)
)
l
)
)
(list
(list (cos r) (sin (- r)) 0.0)
(list (sin r) (cos r) 0.0)
'(0.0 0.0 1.0)
)
)
)
(mapcar '(lambda (x) (trans x n 0)) l)
)
(if (> (vla-get-Count (setq objcoll (al-selectonscreen '((0 . "*TEXT"))))) 0)
(vlax-for obj objcoll
(setq ptlst (apply 'append (getTextBox obj)))
(setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlst) 1))))
(vlax-safearray-fill tmp ptlst)
(setq myobj (vla-addPolyline (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) tmp))
(vla-put-Closed myobj -1)
)
)
)