Here is another way to approach the task:

Code:

;; Text Point - Lee Mac
;; Prompts the user to specify the location of a point relative to a single text object
;; and generates a point in the same location relative to every text object in a selection.
(defun c:txp ( / ang ent enx idx ocs sel vec )
(while
(progn (setvar 'errno 0)
(setq ent (car (entsel "\nSelect source text object: ")))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (null ent) nil)
( (/= "TEXT" (cdr (assoc 0 (entget ent))))
(princ "\nSelected object is not a text object.")
)
)
)
)
(if (and (= 'ename (type ent))
(setq vec (getpoint "\nSpecify point: "))
(setq sel (ssget '((0 . "TEXT"))))
)
(progn
(setq
enx (entget ent)
ang (cdr (assoc 050 enx))
ocs (cdr (assoc 210 enx))
vec
(mxv
(mxm
(list
(list (/ 1.0 ((lambda ( box ) (- (caadr box) (caar box))) (textbox enx))) 0.0 0.0)
(list 0.0 (/ 1.0 (cdr (assoc 040 enx))) 0.0)
'(0.0 0.0 1.0)
)
(mxm
(list
(list (cos ang) (sin ang) 0.0)
(list (- (sin ang)) (cos ang) 0.0)
'(0.0 0.0 1.0)
)
(mapcar '(lambda ( v ) (trans v ocs 0 t))
'(
(1.0 0.0 0.0)
(0.0 1.0 0.0)
(0.0 0.0 1.0)
)
)
)
)
(mapcar '- (trans vec 1 0) (trans (cdr (assoc 10 enx)) ent 0))
)
)
(repeat (setq idx (sslength sel))
(setq enx (entget (ssname sel (setq idx (1- idx))))
ang (cdr (assoc 050 enx))
ocs (cdr (assoc 210 enx))
)
(entmake
(list
'(0 . "POINT")
(cons 10
(mapcar '+ (trans (cdr (assoc 10 enx)) ocs 0)
(mxv
(mxm
(mapcar '(lambda ( v ) (trans v 0 ocs t))
'(
(1.0 0.0 0.0)
(0.0 1.0 0.0)
(0.0 0.0 1.0)
)
)
(mxm
(list
(list (cos ang) (- (sin ang)) 0.0)
(list (sin ang) (cos ang) 0.0)
'(0.0 0.0 1.0)
)
(list
(list ((lambda ( box ) (- (caadr box) (caar box))) (textbox enx)) 0.0 0.0)
(list 0.0 (cdr (assoc 040 enx)) 0.0)
'(0.0 0.0 1.0)
)
)
)
vec
)
)
)
)
)
)
)
)
(princ)
)
;; Matrix Transpose - Doug Wilson
;; Args: m - nxn matrix
(defun trp ( m )
(apply 'mapcar (cons 'list m))
)
;; Matrix x Matrix - Vladimir Nesterovsky
;; Args: m,n - nxn matrices
(defun mxm ( m n )
((lambda ( a ) (mapcar '(lambda ( r ) (mxv a r)) m)) (trp n))
)
;; Matrix x Vector - Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
(defun mxv ( m v )
(mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)
(princ)

The above will account for the varying position, rotation, width, height & orientation of every text object in the selection, and will also perform correctly under all UCS & View settings.

## Bookmarks