Visual LISP, AutoLISP and General Customization

Reply
Mentor
richie.hodgson
Posts: 208
Registered: ‎11-05-2008
Message 1 of 7 (171 Views)

change an attribute text

171 Views, 6 Replies
06-24-2012 06:09 PM

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
*Expert Elite*
pbejse
Posts: 2,437
Registered: ‎11-24-2009
Message 2 of 7 (161 Views)

Re: change an attribute text

06-24-2012 10:14 PM 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

 

 

 

Mentor
richie.hodgson
Posts: 208
Registered: ‎11-05-2008
Message 3 of 7 (142 Views)

Re: change an attribute text

06-25-2012 05:58 PM in reply to: richie.hodgson

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
*Expert Elite*
pbejse
Posts: 2,437
Registered: ‎11-24-2009
Message 4 of 7 (137 Views)

Re: change an attribute text

06-25-2012 09:01 PM 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")
            )

 

Mentor
richie.hodgson
Posts: 208
Registered: ‎11-05-2008
Message 5 of 7 (129 Views)

Re: change an attribute text

06-26-2012 01:26 AM in reply to: richie.hodgson

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
Mentor
richie.hodgson
Posts: 208
Registered: ‎11-05-2008
Message 6 of 7 (108 Views)

Re: change an attribute text

06-26-2012 07:17 PM in reply to: richie.hodgson

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

Richie
*Expert Elite*
pbejse
Posts: 2,437
Registered: ‎11-24-2009
Message 7 of 7 (101 Views)

Re: change an attribute text

06-26-2012 09:48 PM 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. :smileyhappy:

 

Cheers

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community