Lisp to add Prefix/Suffix to selected Attribute in a block

Lisp to add Prefix/Suffix to selected Attribute in a block

Anonymous
Not applicable
4,061 Views
4 Replies
Message 1 of 5

Lisp to add Prefix/Suffix to selected Attribute in a block

Anonymous
Not applicable
Hi, I'm still new in Lisps, if you can help in below I need to add (m²) as a Suffix to an existing attribute within a block, I don't want to add the m² to all attributes, just selected one, I found some Lisps but most of them either add to all attributes within a block or don't recognize the (²) symbol if you can help me in simple Lisp that allow me to identify which attribute to add to, and allow me to select multiple blocks together and recognize symbols many thanks in advance
0 Likes
4,062 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Iam attaching a Lisp that works well , by selecting the attribute tag ( named "area") in Lisp, yet it don't recognize the m2 symbol when I try to write it is there a way we can modify the Lisp to work with what I need ? attached Lisp
0 Likes
Message 3 of 5

Anonymous
Not applicable
attached
0 Likes
Message 4 of 5

_Tharwat
Advisor
Advisor

Hi,

 

Try this UNTESTED program and let me know.

 

(defun c:Test (/ s i st)
  ;; 	Tharwat 08.08.2016	;;
  (princ "\nSelect attributed blocks to add [m²] to area tags only.")
  (if (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1))))
     (repeat (setq i (sslength s))
             (foreach att (vlax-invoke (vlax-ename->vla-object (ssname s (setq i (1- i)))) 'Getattributes)
               (and (= (strcase (vla-get-tagstring att)) "AREA")
                    (not (wcmatch (setq st (vla-get-textstring att)) "*m²"))
                    (vla-put-textstring att (strcat st "m²")))
               )
       )
    )
  (princ)
)
(vl-load-com)
Message 5 of 5

3wood
Advisor
Advisor

You can try ALTEXT, settings as below:

Capture.jpg

0 Likes