Block Attributes - changing values?

Discussion in 'AutoCAD' started by dhorton, Aug 5, 2004.

  1. dhorton

    dhorton Guest

    Hello,

    I'm trying to create a LISP routine that would replace a known value within a known block. There are multiple insertions of the the block within the drawing. The block also contains a number of attributes.
    I'm new to LISP. but have so far managed to use entmod to change values of attributes. I'm after away, I think by using selection sets, to select all block attributes with the variable to change.....
    Any help would be greatly appreciated........useful hints etc., as i'm trying to learn!

    Cheers,

    Dom
     
    dhorton, Aug 5, 2004
    #1
  2. dhorton

    OLD-CADaver Guest

    I may be confused as to what you're after, but -ATTEDIT does exactly what you've asked for in the first line of your post, without any lisp. You can even ask it to select those attributes by value, and you can modify only the selected blocks, or globally edit all instances of the value in an attribute.
     
    OLD-CADaver, Aug 5, 2004
    #2
  3. dhorton

    dhorton Guest

    Thanks for the reply, ATTEDIT seems to do the trick!
    To progress things further, how would one go about creating a selection set of blocks with a particular attribute of known value?

    Thanks
     
    dhorton, Aug 5, 2004
    #3
  4. Old school method (no vlax) -

    (setq BN "YourBlockName")
    (setq AN "YourAttributeName")
    (setq NA "NewAttributeValue")
    (if (setq SS (ssget "X" (list (cons 0 "INSERT") (cons 2 BN))))
    (progn
    (setq KK 0 KS (sslength SS))
    (while (< KK KS)
    (setq EG (entget (ssname SS KK)))
    (setq EN (entget (entnext (cdr (assoc -1 EG)))))
    (while (and EN (/= (cdr (assoc 0 EN)) "SEQEND"))
    (if (= (cdr (assoc 2 EN)) AN)
    (progn
    (setq EN (subst (cons 1 NA) (assoc 1 EN) EN))
    (entmod EN)
    (entupd (cdr (assoc -1 EG)))
    (setq EN nil)
    )
    (setq EN (entget (entnext (cdr (assoc -1 EN)))))
    )
    )
    (setq KK (1+ KK))
    )
    )
    (alert (strcat "\nNote - Block [" BN "] NOT found."))
    )
     
    Alan Henderson @ A'cad Solutions, Aug 5, 2004
    #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.