Attribute data

Discussion in 'AutoCAD' started by iwafb, May 17, 2004.

  1. iwafb

    iwafb Guest

    Hello all,

    I'm trying to write a lisp function to check the value assigned to a particular entity within an attribute (drawing block) and ammend the value if needed.

    When I cycle (entnext) to the desired entity, the dotted pair 1 returns "" (the default in the block) and dotted pair 2 returns "A" (the tag in the block). No matter how I revise the block (dda or eattedit) it still returns the same values. Is there a way of returning what the actual "text" value is in the drawing? I am using 2002.

    Thanks in advance
    John
     
    iwafb, May 17, 2004
    #1
  2. iwafb

    ECCAD Guest

    It looks like you are seeing the 'block definition' from the 'block' table. Try using ssget, pick a block, and examine that.
    This would be an 'INSERT' entity.

    Bob
     
    ECCAD, May 17, 2004
    #2
  3. iwafb

    ECCAD Guest

    Or, maybe you are looking at an 'ATTDEF' entity ?
    Bob
     
    ECCAD, May 17, 2004
    #3
  4. iwafb

    Jamie Duncan Guest

    Here is a function to get the value of one specified attribute and a given
    layer


    (defun getoneattribute ( attrib layname msg / data ent enval )
    (setq enval nil)
    (while
    (not
    (and
    (setq ent (entsel msg))
    (= "INSERT" (cdr (assoc 0 (entget (car ent)))))
    (= layname (cdr (assoc 8 (entget (car ent)))))
    )
    )
    )
    (setq ent (car ent) data (entget ent))
    (while (not (eq (cdr (assoc 0 data)) "SEQEND"))
    (setq ent (entnext ent))
    (setq data (entget ent))
    (if
    (and
    (= (cdr (assoc 0 data)) "ATTRIB")
    (= (cdr (assoc 2 data)) attrib)
    )
    (setq enval (cdr (assoc 1 data)))
    )
    )
    enval;;;return value or nil
    );;; end of function


    so say you had an atribbute "DATA", in a block on layer "A_ANNO"

    you would, with the above function loaded send:

    (getoneattribute "DATA" "A_ANNO" "Please Select A Block: ")

    Jamie Duncan


    particular entity within an attribute (drawing block) and ammend the value
    if needed.
    (the default in the block) and dotted pair 2 returns "A" (the tag in the
    block). No matter how I revise the block (dda or eattedit) it still returns
    the same values. Is there a way of returning what the actual "text" value is
    in the drawing? I am using 2002.
     
    Jamie Duncan, May 17, 2004
    #4
  5. iwafb

    Joe Burke Guest

    John and Bob,

    I think you want to use nentsel.

    Command: (setq elst (entget (car (nentsel "Select attribute "))))
    Select attribute ((-1 . <Entity name: 7ef68a00>) (0 . "ATTRIB") (330 . <Entity
    name: 7ef689f8>) (5 . "8BA0") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8
    .. "0") (100 . "AcDbText") (10 811.051 -212.353 0.0) (40 . 9.6) (1 . "C") (50 .
    0.0) (41 . 0.9) (51 . 0.0) (7 . "Romans") (71 . 0) (72 . 4) (11 815.371
    -207.553 0.0) (210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "GRIDNO") (70 . 0)
    (73 . 0) (74 . 0))

    Command: (setq str (cdr (assoc 1 elst)))
    "C"

    Joe Burke

    entity within an attribute (drawing block) and ammend the value if needed.
    default in the block) and dotted pair 2 returns "A" (the tag in the block). No matter
    how I revise the block (dda or eattedit) it still returns the same values. Is there a
    way of returning what the actual "text" value is in the drawing? I am using 2002.
     
    Joe Burke, May 17, 2004
    #5
  6. iwafb

    John Guest

    How do you get information from

    (100 . "AcDbEntity")
    (100 . "AcDbText")
    (100 . "AcDbAttribute")

    Command: (setq str (cdr (assoc 100 elst)))????????????????

    John
     
    John, May 17, 2004
    #6
  7. iwafb

    ECCAD Guest

    Joe,
    I don't think that is what he wanted. It would merely return the 'value' of the chosen attribute - picked. Since he is to 'pick' it, the 'value' is there on the screen. Redundant ?
    I think he wants to examine block insert, dig into the attributes, obtain the value string, and change it if need be.
    (unless I'm wrong)
    ::)
    Bob
     
    ECCAD, May 17, 2004
    #7
  8. iwafb

    Jamie Duncan Guest

    nentsel only works for visible attributes.

    Jamie Duncan
     
    Jamie Duncan, May 17, 2004
    #8
  9. iwafb

    ECCAD Guest

    John,
    Did you get the 'values' pulled-out yet ?
    Bob
     
    ECCAD, May 17, 2004
    #9
  10. iwafb

    Jürg Menzi Guest

    John

    Visit my Homepage -> Free Stuff and search for VxGetAtts/VxSetAtts...

    Cheers
     
    Jürg Menzi, May 17, 2004
    #10
  11. iwafb

    John Guest

    No :( But keep trying :)

    John
     
    John, May 17, 2004
    #11
  12. iwafb

    ECCAD Guest

    By chance, is the 'value' burried in edata ? in dictionary ?

    Bob
     
    ECCAD, May 17, 2004
    #12
  13. iwafb

    Joe Burke Guest

    Bob,

    Regarding John's initial question... what's not clear, to me anyway, is how he
    intends to select whatever. Maybe you are better at mind-reading than me. :)

    Joe Burke
    chosen attribute - picked. Since he is to 'pick' it, the 'value' is there on the
    screen. Redundant ?
    string, and change it if need be.
     
    Joe Burke, May 17, 2004
    #13
  14. iwafb

    ECCAD Guest

    When I cycle (entnext) to the desired entity,....<<
    Bob
     
    ECCAD, May 17, 2004
    #14
  15. iwafb

    ECCAD Guest

    John,
    If you want, you could E-Mail me a sample .dwg to look at, and which block / attrib you need..

    remove the nospam.

    I will take a peek at the data and see what I can find..
    No charge.

    Bob
     
    ECCAD, May 17, 2004
    #15
  16. iwafb

    Jamie Duncan Guest

    John,

    did you want one attribute value? from one block-insert, or many?

    or all attribute values from a block-insert?

    Jamie Duncan
     
    Jamie Duncan, May 17, 2004
    #16
  17. iwafb

    John Guest

    Bob and Jamie

    I just posted cad ADT 3.3 file at autodesk.autocad.customer-files (Subject
    Attribute data).

    John
     
    John, May 17, 2004
    #17
  18. iwafb

    John Guest

    Some reason i was not able to send file at your email address.

    Thanks.

    John
     
    John, May 17, 2004
    #18
  19. iwafb

    ECCAD Guest

    John,
    You need to make 'blocks' of your "Aec_Room_Tag_P", and other blocks - then '-insert' them, fill in the scaleX, scaleY, rotation, and fill in the attributes. Existing sample drawing has block definitions, but when inserted, they appear as 'Attdef' entities only.

    Once you re-define them as 'blocks', then data extraction will work as we discussed before.

    Hope this helps.

    Bob Shaw
     
    ECCAD, May 17, 2004
    #19
  20. iwafb

    Jeff Mishler Guest

    John, I don't use ADT so this may be offline.
    The MultiView block that contains the room name and number has 3 attributes,
    the room name, the room number, and the room height.
    To get these use something like this:

    (setq insBlk (car (entget "\nSelect room: ")))
    (setq lstBlk (entget insBlk))
    (foreach x elist
    (if (= (car x) 1)
    (setq ones (cons (cdr x) ones))
    )
    )
    (setq ones (reverse ones))

    This will return a list of the attribute values in the order of name,
    number, height

    If you need to change one, just do this:
    (setq lstBlk (subst (cons 1 "newdata") (cons 1 (nth 0 ones)) lstBlk)) ; nth
    0 or nth 1 or nth 2, depending on which one you wish to revise
    (entmod lstblk)

    HTH,
    Jeff
     
    Jeff Mishler, May 17, 2004
    #20
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.