This problem was also posted here:I know, that was my post, here is solution,
http://www.cadtutor.net/forum/showthread.php?97195-Lisp-Minimum-bounding-box-for-rotated-attribute-block
;;ziele_o2k
;;v20160615-1216
(defun c:final ( / *error* ss in blkent attentlst Att-0 Att-1 Att-2 box os)
(defun *error* (msg / so)
(cond
((not msg))
((member msg '("Function cancelled" "quit / exit abort")))
(
(princ (strcat "\n <!> Error: " msg " <!> "))
(cond (T (vl-bt)))
)
)
(princ)
)
(if(setq ss (ssget '((0 . "INSERT") (2 . "GT-SP-TYP2") (66 . 1))))
(progn
(repeat (setq in (sslength ss))
(setq blkent (ssname ss (setq in (1- in))))
(setq attentlst (cd:BLK_GetAttEntity blkent))
(foreach %1 attentlst
(
(lambda (%2)
(cond
((eq (cdr (assoc 2 (entget %2))) "NUMBER") (setq Att-0 (entget %2)))
((eq (cdr (assoc 2 (entget %2))) "SEPARATOR") (setq Att-1 (entget %2)))
((eq (cdr (assoc 2 (entget %2))) "LEVEL") (setq Att-2 (entget %2)))
)
)
%1
)
)
(if (and Att-0 Att-1 Att-2)
(progn
(setq box (textbox Att-0))
(setq os (/ (cdr (assoc 40 Att-1)) 8))
(setq
Att-1
(subst
(cons
10
(polar
(cdr (assoc 10 Att-0))
(cdr (assoc 50 Att-0))
(+ (caadr box) os)
)
)
(assoc 10 Att-1)
Att-1
)
Att-1 (subst (assoc 50 Att-0)(assoc 50 Att-1)Att-1)
)
(entmod Att-1)
(setq box (textbox Att-1))
(setq
Att-2
(subst
(cons 10
(polar
(cdr (assoc 10 Att-1))
(cdr (assoc 50 Att-1))
(+ (caadr box) os)
)
)
(assoc 10 Att-2)
Att-2
)
Att-2 (subst (assoc 50 Att-1)(assoc 50 Att-2)Att-2)
)
(entmod Att-2)
(entupd blkent)
)
(princ "\nNo atts.")
)
)
)
)
)
There is still problem when we have spaces in begining or end of attribute string. Textbox function ignores that spaces.(textbox (entmod (subst ...)))
Can become:(textbox (subst ...))
@ ziele-o2k:New version of textbox.
As I tried to explain in your thread on the other forum (http://www.cadtutor.net/forum/showthread.php?97195-Lisp-Minimum-bounding-box-for-rotated-attribute-block&p=663680&viewfull=1#post663680), there is no need to actually change an entity for the (textbox) function. You can completely remove entmod (3x) from your PZ:TextBox function.Code: [Select](textbox (entmod (subst ...)))
Can become:Code: [Select](textbox (subst ...))
(strlen "abc")
(vl-string-trim " " " A ")
(wcmatch " abc " " *,* ")
Three functions that may be usefull:Code: [Select](strlen "abc")
(vl-string-trim " " " A ")
(wcmatch " abc " " *,* ")