Change Attributes, changes all blocks.

Discussion in 'AutoCAD' started by Greg McLandsborough, Sep 11, 2003.

  1. This code is driving me silly..

    (defun mm-put-entity-att-value
    (Block-Ent TagString Textstring / Block-Set Block-Entity Block-Next
    cnt)
    (setq Block-Next Block-Ent)
    (while (setq Block-Next (entnext Block-Next))
    (if (= (dxf 0 (setq Block-Entity (entget Block-Next))) "ATTRIB")
    (if (= (dxf 2 Block-Entity) TagString)
    (progn
    (entmod (subst (cons 1 Textstring) (assoc 1 Block-Entity)
    Block-Entity))
    (entupd Block-Ent)
    )
    )
    )
    )
    )

    I use it to select a single block, ie my material list, which is the same
    block inserted many times. I change on Block-Ent which is pass a ename, but
    several of the blocks are updated, sometimes all, but not always. Does
    anyone know what I doing wrong ??
     
    Greg McLandsborough, Sep 11, 2003
    #1
  2. Dont worry to much folks, sorted it with ActiveX.

    (defun mm-put-entity-att-value
    (Block-Ent TagString Textstring / Block-Set Block-Entity Block-Next
    cnt)
    (setq
    Attribute-list (vlax-safearray->list
    (vlax-variant-value (vla-getattributes (vlax-ename->vla-object
    Block-Ent)))
    ) ;_ end of vlax-safearray->list
    ) ;_ end of setq
    (foreach Attribute Attribute-List
    (if
    (= TagString (vla-get-TagString Attribute))
    (setq Attribute-Value (vla-put-TextString Attribute Textstring))
    )
    )
    )


    Thanks anyway
     
    Greg McLandsborough, Sep 11, 2003
    #2
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.