Results 1 to 2 of 2

Thread: Swap Attribute Values in Block

  1. #1
    Member
    Join Date
    2015-09
    Posts
    8
    Login to Give a bone
    0

    Default Swap Attribute Values in Block

    I have a specific block called ARROW_R that has four attributes but only two that need to be swapped TO and FROM. Of course there are hundreds of these blocks in the drawing and they are backwards. I have a lisp that I can click one then the other and they swap but I don't relish many hundreds of clicks, especially since there are many of these drawings to do. I am looking for either an across the board change or a selection set and swap.

    I just can't seem to figure this out so any help would be appreciated.

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Swap Attribute Values in Block

    You use a Get & Put via Vlisp is the easiest. This is a method example make sure you do the Get 1st for the two attribute textstrings then do the put.

    Code:
    ; this is not tested !!!
    ; update title block rev label by entering
    : by AH DEC 2012
    
    (vl-load-com)
    
    (defun updatetitblk ( / plotabs len lay title width limit newstr4 ss1)
    
    (setq bname "DA1DRTXT")
    
          (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)))
          (setq x (sslength ss1))
          (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq x (- x 1)) )) 'getattributes)
            (if (= "REV_NO" (strcase (vla-get-tagstring att)))
            (setq t1 (vla-get-textstring att ))
            ) ; end if
           (if (= "REV_NO2" (strcase (vla-get-tagstring att)))
            (setq t2 (vla-get-textstring att ))
            ) ; end if
          ) ; end foreach
    
     (setq x (sslength ss1))
     (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq x (- x 1)) )) 'getattributes)
           (if (= "REV_NO" (strcase (vla-get-tagstring att)))
            (vla-put-textstring att t2)
            ) ; end if
           (if (= "REV_NO2" (strcase (vla-get-tagstring att)))
            (vla-put-textstring att t1)
            ) ; end if
          ) ; end foreach
    
    
    (setq ss1 nil
          plotabs nil)  
    
    (princ)
    )
    
    (updatetitblk)
    Last edited by BIG-AL; 2017-03-31 at 08:11 AM.

Similar Threads

  1. 2015: Mapbook with list of block attribute values
    By brentwride411655 in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2015-06-26, 09:55 PM
  2. Clear All Attribute Values In a Block
    By CADdancer in forum AutoLISP
    Replies: 13
    Last Post: 2014-05-27, 12:22 PM
  3. How to change dynamic block attribute default values based on block selected?
    By zeirz109180 in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2013-12-13, 02:20 PM
  4. Block Attribute Table Values Dont' Appear in Block
    By stusic in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2011-12-27, 02:58 PM
  5. Using Attribute values to control Dynamic Block actions
    By bshank.140587 in forum Dynamic Blocks - Technical
    Replies: 5
    Last Post: 2007-06-17, 02:12 AM

Posting Permissions

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