copy attribute values

Discussion in 'AutoCAD' started by jlspartz, Jan 4, 2005.

  1. jlspartz

    jlspartz Guest

    I want to be able to select a block (room tag) and have it copy the text out of the 1st text value and place it in the 14th, and then the 2nd value to the 15th. Can anyone share with me some code for doing this?
     
    jlspartz, Jan 4, 2005
    #1
  2. jlspartz

    T.Willey Guest

    Do you know what the tags for all of them are? Because you could do a while loop with either the "GetAttributes" of vlisp or "Entnext" of regular lisp and just search for the tag values, then do what you need to do with them.

    Tim

    (while (setq AttEnt (entnext Attent))
    (setq AttData (entget AttEnt))
    (setq TagValue (cdr (assoc 2 AttData)))
    (cond
    ((= TagValue "Tag1")
    (setq Val1 (cdr (assoc 1 AttData)))
    )
    ((= TagValue "Tage14")
    (entmod (subst (cons 1 Val1) (assoc 1 AttData) AttEnt))
    )
    )
    )

    Something like that.
     
    T.Willey, Jan 4, 2005
    #2
  3. jlspartz

    jlspartz Guest

    The block name is EXRMNAME.

    The tag names are:

    1st NameX
    2nd Name
    14th NameY
    15th NameZ

    So, NameX needs to be copied to NameY, and Name to NameZ.
     
    jlspartz, Jan 4, 2005
    #3
  4. jlspartz

    T.Willey Guest

    This should get you going.

    Tim

    (defun c:UdateValues (/ ss Ent Att AttData Val1 Val2)

    (if (setq ss (ssget "x" '((2 . "EXRMNAME"))))
    (while (setq Ent (ssname ss 0))
    (setq Att Ent)
    (while (setq Att (entnext Att))
    (setq AttData (entget Att))
    (cond
    ((= "NAMEX" (cdr (assoc 2 AttData)))
    (setq Val1 (cdr (assoc 1 AttData)))
    )
    ((= "NAME" (cdr (assoc 2 AttData)))
    (setq Val2 (cdr (assoc 1 AttData)))
    )
    ((= "NAMEY" (cdr (assoc 2 AttData)))
    (entmod (subst (cons 1 Val1) (assoc 1 AttData) AttData))
    )
    ((= "NAMEz" (cdr (assoc 2 AttData)))
    (entmod (subst (cons 1 Val2) (assoc 1 AttData) AttData))
    )
    )
    )
    (ssdel Ent ss)
    )
    (prompt "\n No blocks name \"EXRMNAME\" in the drawing.")
    )
    (princ)
    )
     
    T.Willey, Jan 4, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.