Visual LISP, AutoLISP and General Customization
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

change an attribute text

6 REPLIES 6
Reply
Message 1 of 7
richie_hodgson
455 Views, 6 Replies

change an attribute text

This has probably been done over and over but I am not undersatanding. I have a block "MANAGER" with Two Attributes "CETOP" and "CEBOT" I would like a lisp to replace what ever is in those attributes with defined text, for my purposes "Text1" and "Text2". I would like a simple routine that even I can understand so I can apply it to a couple of other lisp projects I have.

Richie
6 REPLIES 6
Message 2 of 7
pbejse
in reply to: richie_hodgson


@richie_hodgson wrote:

This has probably been done over and over but I am not undersatanding. I have a block "MANAGER" with Two Attributes "CETOP" and "CEBOT" I would like a lisp to replace what ever is in those attributes with defined text, for my purposes "Text1" and "Text2". I would like a simple routine that even I can understand so I can apply it to a couple of other lisp projects I have.



The Vanilla code posted on your other thread is a s simple as it can be richie.

If you want a generic code:

 

(defun Revall  (dat_ bn / att# sset e an ad )
      (if  (setq sset (ssget "_X" (list '(0 . "INSERT")'(66 . 1) (cons 2 bn))))
            (progn
                  (prompt "\nupdating.......please wait. ")
                  (while (setq e (ssname sset 0))
                        (setq an (entnext e)
                              ad (entget an))
                        (while (= "ATTRIB" (cdr (assoc 0 ad)))
                              (if (setq val (assoc (cdr (assoc 2  ad)) dat_))
                                    (setq ad (entmod (subst (cons 1 (cadr val))
                                                    (assoc 1 ad)
                                                    ad)))
                                         
                                    )
                              (setq an (entnext an)
                                    ad (entget an))
                              )
                        (ssdel e sset)
                        )
                  )
 )
      (princ)
      )

 

(defun c:CTV  (/ bn tag val data)       ;Chagne TagString value
      (setq bn  "MANAGER"
            tag '("CETOP" "CEBOT"))
      (foreach
             tg  tag
            (setq val  (getstring  t
                             (strcat
                                   "\nEnter New String Value for TAG " tg
                                   ": ")))
            (setq data (cons (list tg val) data)))
      (if data
            (Revall data bn)
            ))

 

You can create as many command name as you please and change the TAG and BN  for specific block

 

(defun c:CTV2  (/ bn tag val data)  

       (setq bn  "AnotherBlockName"

            tag '("TAG1" "TAG2 "TAG3"))

.....

 

)

HTH

 

 

 

Message 3 of 7

Hi, many thanks for that, what I am trying to do is put 2 lines of "pre-set" text in those attributes, (setq txt1 "Line1 text") (setq txt2 "Line 2 Text"), so txt1 goes into CETOP and txt2 goes into CEBOT I can see how your code works but not sure how to do this bit with the way you have coded it.

Richie
Message 4 of 7
pbejse
in reply to: richie_hodgson


@richie_hodgson wrote:

Hi, many thanks for that, what I am trying to do is put 2 lines of "pre-set" text in those attributes, (setq txt1 "Line1 text") (setq txt2 "Line 2 Text"), so txt1 goes into CETOP and txt2 goes into CEBOT I can see how your code works but not sure how to do this bit with the way you have coded it.


(defun c:reman  nil
 (Revall '(("CETOP" "Line1 text")("CEBOT" "Line 2 text"))  "MANAGER")
            )

 

Message 5 of 7

That has made me very happy, will try it out tomorrow when I get some time, Gives me two good methos to approach attribute manipulation

Richie
Message 6 of 7

Many thanks, it all works beautifully, have made a couple of changes to suit.

Richie
Message 7 of 7
pbejse
in reply to: richie_hodgson


@richie_hodgson wrote:

Many thanks, it all works beautifully, have made a couple of changes to suit.


You're welcome. Smiley Happy

 

Cheers

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

ā€Boost