TROYDAWES wrote:In the block, there are 2 separate attributes
1st attribute is the Fixture units, in the block I use, the TAG = FU, PROMPT = Number of fixture units, DEFAULT = (x)
2nd attribute is the Pipe size, in the block I use, the TAG = PS, PROMPT = Pipe Size, DEFAULT = y
(defun c:demo ( / table blks i e fu ps) (vl-load-com)
;;; This is where you add additional values ;;; (min max string) ;;; (1 10 "value")
(setq table '((0.5 1.0 "½")(1.5 7.0 "3/4") (7.5 17.0 "1")(17.5 36.0 "1¼")))
(if (setq blks (ssget "_X" '((0 . "INSERT") (2 . "FU-PS-RIGHT,FU-PS-LEFT")))) (repeat (setq i (sslength blks)) (setq val (vlax-invoke (setq e (vlax-ename->vla-object (ssname blks (setq i (1- i))))) 'GetAttributes)) (if (and (setq fu (car (read (vla-get-textstring (Car val))))) (setq ps (vl-some '(lambda (x) (if (<= (Car x) fu (cadr x)) (last x) nil)) table))) (vla-put-textstring (Cadr val) ps)) ) )(princ) )
Now you can use formula in ALTEXT.
Please try attached ALTEXT.vlx, and select "Use formula" and the bottom. When it prompts to select a lisp file as the formula, pick up ALTEXT_formula.lsp
You can expand/modify the condition defined in ALTEXT_formula.lsp as you like.