The one bit I keep forgetting... add this code in after the first line and see what it does
(defun getent ( aprompt / enta entb pt )
(princ "\n")
(setq enta (car (nentsel aprompt)))
(setq pt (cdr (assoc 10 (entget enta))) )
;;;;fix for nenset or entsel requirements
(setq entb (last (last (nentselp pt))))
(if (and (/= entb nil) (/= (type entb) 'real) )
(progn
(if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION")(setq enta entb))
)
)
enta
)
It should now be and your dimension will be shown in the command line text01 in this LISP ready to add to a table
(defun c:dynamicdimtext ( / ent1 entcodes1 entlist1 text01 )
(defun getent ( aprompt / enta entb pt )
(princ "\n")
(setq enta (car (nentsel aprompt)))
(setq pt (cdr (assoc 10 (entget enta))) )
;;;;fix for nenset or entsel requirements
(setq entb (last (last (nentselp pt))))
(if (and (/= entb nil) (/= (type entb) 'real) )
(progn
(if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION")(setq enta entb))
)
)
enta
)
(defun getfroment (ent entcodes / acount acounter mytext newtext stringtext)
;;get dotted pairs list
(setq entlist (entget ent))
(setq acount 0)
(while (< acount (length entlist))
(setq acounter 0)
(while (< acounter (length entcodes))
(setq entcode (nth acounter entcodes))
(if (= (car (nth acount entlist)) entcode )
(progn
(setq newtext (cdr (nth acount entlist)))
(if (numberp newtext)(setq newtext (rtos newtext))) ;fix for real numbers
(setq mytext (append mytext (list (cons (car (nth acount entlist)) newtext) )) )
);end progn
);end if
(setq acounter (+ acounter 1))
);end while
(setq acount (+ acount 1))
);end while
;;get string from dotted pair lists
(if (> (length mytext) 0)
(progn
(setq acount 0)
(setq temptext "")
(while (< acount (length mytext))
(setq temptext (cdr (nth acount mytext)) )
(if (= stringtext nil)
(setq stringtext temptext)
(setq stringtext (strcat stringtext temptext ))
);end if
(setq acount (+ acount 1))
);end while
);end progn
);end if
(if (= stringtext nil)(setq stringtext ""))
(setq mytext stringtext)
mytext
)
;;get text as a string
(defun gettextasstring ( enta entcodes / texta )
(if (= (getfroment enta entcodes) "")
()
(setq texta (getfroment enta entcodes))
)
texta
)
;;get text 1
(setq ent1 (getent "\nSelect Dimension : "))
(setq entlist1 (entget ent1))
(setq entcodes1 (list 4 1 172 304))
(setq text01 (gettextasstring ent1 entcodes1) ) ;Text as string
(setq text01 (LM:UnFormat text01 "" ))
(princ text01)
)
;;-------------------=={ UnFormat String }==------------------;;
;; ;;
;; Returns a string with all MText formatting codes removed. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; str - String to Process ;;
;; mtx - MText Flag (T if string is for use in MText) ;;
;;------------------------------------------------------------;;
;; Returns: String with formatting codes removed ;;
;;------------------------------------------------------------;;
(defun LM:UnFormat ( str mtx / _replace rx )
(defun _replace ( new old str )
(vlax-put-property rx 'pattern old)
(vlax-invoke rx 'replace str new)
)
(if (setq rx (vlax-get-or-create-object "VBScript.RegExp"))
(progn
(setq str
(vl-catch-all-apply
(function
(lambda ( )
(vlax-put-property rx 'global actrue)
(vlax-put-property rx 'multiline actrue)
(vlax-put-property rx 'ignorecase acfalse)
(foreach pair
'(
("\032" . "\\\\\\\\")
(" " . "\\\\P|\\n|\\t")
("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]")
("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);")
("$1$2" . "\\\\(\\\\S)|[\\\\](})|}")
("$1" . "[\\\\]({)|{")
)
(setq str (_replace (car pair) (cdr pair) str))
)
(if mtx
(_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str))
(_replace "\\" "\032" str)
)
)
)
)
)
(vlax-release-object rx)
(if (null (vl-catch-all-error-p str))
str
)
)
)
)