attribute check

Discussion in 'AutoCAD' started by John Georgiev, May 14, 2004.

  1. I have a file with one block with one attribute (number) copied many times.
    The value of the attribute should be unique and I want to check that. I
    trying to make routine to do that but I can't point to the attribute, which
    is only one of the many entities. Any help?
     
    John Georgiev, May 14, 2004
    #1
  2. John Georgiev

    Mark Propst Guest

    Do you mean you have a drawing in which is inserted many copies of a block
    insertion(blockreference)?

    and the blockreference has one attribute? and only one attribute?

    and you want to make sure there are no duplicate values stored in the
    attribute value of all of the insertions?

    if BlockName is set to the name of the block you're looking for...
    (setq ss(ssget"x"(list(cons 0 "INSERT")(cons 2 BlockName))))
    gets all the blocks
    (if ss ;if there are any
    (progn
    (setq i 0)
    (repeat(sslength ss);for each one
    (setq thisinsert (ssname ss i))
    (setq vo(vlax-ename->vla-object thisinsert))
    (if(= :vlax-true(vlax-get-property vo 'HasAttributes))
    (setq attriblist
    (vlax-safearray->list
    (vlax-variant-value
    (vla-getAttributes vo)
    )
    );vlax-list
    );sqt

    ;;;if there are more than one - you could compare tags
    (foreach att attriblist
    (setq tag(vlax-get-property att 'tagstring))
    ;if tag matches whatever...

    ;;;or if theres just one, it doesn't matter...
    (setq att(car attriblist))

    ;;;once you have the attribute object
    (setq val(vlax-get-property att 'textstring))

    ;;;keep track of what values have been found
    (if(not(member val listofVals))
    (setq listOfVals(cons val ListOfVals))
    ;assuming val is a string type - adjust accordingly
    (princ (strcat "\nDuplicate record found: " val))
    )

    etc etc etc
     
    Mark Propst, May 15, 2004
    #2
  3. John Georgiev

    bob.at Guest

    John,

    an other possibility is to use Attext to write text file with the attribut values (and also the insert point to find the block) and then load the result into exce, analysing it there.
    The definition file for attext should look like this:
    BL:NAME C010000
    BL:X N020003
    BL:A N020003
    AttName C005000
    where "AttName" ist the name of your attribut

    bob.at
     
    bob.at, May 15, 2004
    #3
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.