• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Distinguished Contributor
    Posts: 123
    Registered: ‎11-05-2008

    change an attribute text

    120 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
    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    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

     

     

     

    Please use plain text.
    Distinguished Contributor
    Posts: 123
    Registered: ‎11-05-2008

    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
    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    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")
                )

     

    Please use plain text.
    Distinguished Contributor
    Posts: 123
    Registered: ‎11-05-2008

    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
    Please use plain text.
    Distinguished Contributor
    Posts: 123
    Registered: ‎11-05-2008

    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
    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    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

    Please use plain text.