Results 1 to 3 of 3

Thread: change value attribute

  1. #1
    Member
    Join Date
    2009-01
    Posts
    33
    Login to Give a bone
    0

    Default change value attribute

    Hi,
    This routine has to change the value of a label if it is equal to the old value.
    I can not figure out what to write to store the new value.
    I hope someone help me to understand ...

    Attached dwg files and lsp

    Thanks.
    bb

    Code:
    ;;This routine should look for attributes in blocks with the tag specified by the operator. 
    ;;;If the label is the law and if its value is equal to old_value changes with the new value.
    ;;NAME TAG: NAME, SURNAME, NATION, CITY
    ;;example if value of city is equalk to york change value in tokio
    
    (defun c:chValue ()
      (vl-load-com)
      (setq tag  (getstring "\n Enter name tag: "))
      (setq old_value (getstring "\n Enter old value: "))
      (setq new_value (getstring "\n Enter new value: "))
      
      (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 66 1)
                    (if (getvar "CTAB")
                      (cons 410 (getvar "CTAB"))
                      (cons 67 (- 1 (getvar "TILEMODE"))))))
         );setq
        (progn
          (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
          (foreach e eLst
        (setq bEnt (cdr (assoc 2 (entget e))))
        (setq aEnt (entnext e))
        (while (= "ATTRIB" (cdr (assoc 0 (setq aEntLst (entget aEnt)))))
          (if (= (cdr (assoc 2 aEntLst)) tag)
            (progn
              (setq aVal (cdr (assoc 1 aEntLst)))
    	  
    
    	   (if ( = aVal old_value)
    
    		(alert "What should I write to store the new value?")
    	     
    	   );if
    	  
            );progn
          );if
          
          (setq aEnt (entnext aEnt))))
        );while
        
        (progn
    	    (princ "\n No block with attribute.")
        );progn
       );if
    
      (alert "ok changed values")
      (princ)
      );def
    Attached Files Attached Files
    Last edited by BlackBox; 2014-10-25 at 04:57 PM. Reason: Please use [CODE] Tags

  2. #2
    Member
    Join Date
    2015-12
    Location
    Israel
    Posts
    2
    Login to Give a bone
    0

    Default Re: change value attribute

    Code:
    (setq
    				junk (alert "What should I write to store the new value?")
    				aEntLst (subst (cons 1 new_value) (assoc 1 aEntLst) aEntLst)
    				junk (entmod aEntLst)
    			)
    Last edited by BlackBox; 2014-10-25 at 04:58 PM. Reason: Please use [CODE] Tags

  3. #3
    Member
    Join Date
    2009-01
    Posts
    33
    Login to Give a bone
    0

    Default Re: change value attribute

    Hi, it works perfectly, thanks a lot.

    But if I have a block with attributes that is contained within a block of drawing as posswo modify the routine mdo that functions?
    I explained well?

    Have you any idea?

    Attached file cad

    Thanks.
    bb
    Attached Files Attached Files

Similar Threads

  1. Replies: 13
    Last Post: 2012-09-18, 07:51 PM
  2. Change titleblock attribute value throughout DWG
    By andersonjg in forum AutoCAD LT - General
    Replies: 7
    Last Post: 2012-04-30, 07:40 AM
  3. My attribute *will not* change layers!!!!!
    By cargo33us120260 in forum AutoCAD General
    Replies: 4
    Last Post: 2007-05-02, 10:51 PM
  4. Change Text to Attribute
    By bhughes.68125 in forum AutoLISP
    Replies: 10
    Last Post: 2004-09-14, 09:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •