Files
lisp-scr/textToValue.lsp

37 lines
1.1 KiB
Common Lisp

(defun C:textToValue (/ tt readval bb)
;; (setq i 0);counter to zero
;; (setq imax 1);while variable
(vl-load-com)
(graphscr)
(setq tt (entsel "\nPick text object"))
(setq readval (print (cdr (assoc 1 (entget (car tt))))))
(setq bb (entsel "\nPick block with attribute"))
(LM:setattributevalue (car bb) "HEIGHT" readval)
)
;; Set Attribute Value - Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - [ent] Block (Insert) Entity Name
;; tag - [str] Attribute TagString
;; val - [str] Attribute Value
;; Returns: [str] Attribute value if successful, else nil.
(defun LM:setattributevalue ( blk tag val / enx )
(if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))
(if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
(if (entmod (subst (cons 1 val) (assoc 1 (reverse enx)) enx))
(progn
(entupd blk)
val
)
)
(LM:setattributevalue blk tag val)
)
)
)