Results 1 to 10 of 10

Thread: Block Attribute "Prompt" Text

  1. #1
    100 Club
    Join Date
    2008-08
    Location
    Vancouver, BC
    Posts
    105
    Login to Give a bone
    0

    Default Block Attribute "Prompt" Text

    I have a lisp that selects a block and gets all the attribute tags and values and writes them to a list.

    I would also like to write the Prompt string to a list, but there does not appear to be a entity group code for Prompt like there is for Tag and Value. Anyone have any ideas ?

    Here is my code:

    Code:
    (defun c:attlist (/ taglist vallist blkatt BORSS ename ATTAG ATTVAL
                        attcurtag attcurval get_blk blkename)
      (setq get_blk
        (car (entsel "\nPick a BLOCK to find the Attribute Tag and Value: "))
      )
      (setq BORSS (entget get_blk))
      (if (= (cdr (assoc 0 BORSS)) "INSERT")
        (progn
          (setq blkatt BORSS)
          (setq blkename (cdr (assoc -1 blkatt)))
          (if (= (cdr (assoc 66 blkatt)) 1)
            (progn
              (while (/= "SEQEND" (cdr (assoc 0 blkatt)))
                (setq ATTAG (cdr (assoc 2 blkatt)))  ;Definition
                (setq ATTVAL (cdr (assoc 1 blkatt)))  ;value
                (setq attcurtag (list ATTAG))
                (setq attcurval (list ATTVAL))
                (setq taglist (append attcurtag taglist))
                (setq vallist (append attcurval vallist))
                (setq blkatt (entget (setq blkename (entnext blkename))))
              )
            )
            (princ)
          )       
          (princ)
        )
        (princ)
      )
      (if vallist (setq vallist (cdr (reverse vallist))))
      (if taglist (setq taglist (cdr (reverse taglist))))
      (princ "\nValues: ")
      (print vallist)
      (princ "\nTags: ")
      (print taglist)
      (princ)
    )

  2. #2
    Active Member
    Join Date
    2000-12
    Posts
    71
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Try adding the line in red...
    Code:
    (defun c:attlist (/ taglist vallist blkatt BORSS ename ATTAG ATTVAL
                        attcurtag attcurval get_blk blkename)
      (setq get_blk
        (car (entsel "\nPick a BLOCK to find the Attribute Tag and Value: "))
      )
      (setq BORSS (entget get_blk))
      (if (= (cdr (assoc 0 BORSS)) "INSERT")
        (progn
          (setq blkatt BORSS)
          (setq blkename (cdr (assoc -1 blkatt)))
          
          (if (= (cdr (assoc 66 blkatt)) 1)
            (progn
              (while (/= "SEQEND" (cdr (assoc 0 blkatt)))
                (setq ATTAG (cdr (assoc 2 blkatt)))  ;Definition
                (setq ATTVAL (cdr (assoc 1 blkatt)))  ;value
                (setq ATTPMT (cdr (assoc 3 (entget (cdr (assoc -2 (tblsearch "block" ATTAG))))))
                (setq attcurtag (list ATTAG))
                (setq attcurval (list ATTVAL))
    ).....

  3. #3
    100 Club
    Join Date
    2008-08
    Location
    Vancouver, BC
    Posts
    105
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Thanks for the input JSelf. It seems that tblsearch does not recognize ATTAG as a block, it is the attribute definition. I thought using blkatt would work but did not.

  4. #4
    Active Member
    Join Date
    2000-12
    Posts
    71
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Quote Originally Posted by Brian C View Post
    Thanks for the input JSelf. It seems that tblsearch does not recognize ATTAG as a block, it is the attribute definition. I thought using blkatt would work but did not.
    I didn't read your code well enough change ATTAG to get_blk
    (setq ATTPMT (cdr (assoc 3 (entget (cdr (assoc -2 (tblsearch "block" get_blk))))))

  5. #5
    100 Club
    Join Date
    2008-08
    Location
    Vancouver, BC
    Posts
    105
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    It still doesn't work - I think I am trying to read the prompt code from the ATTDEF entity, but not sure how to grab it.
    Last edited by Brian C; 2010-06-15 at 08:48 PM.

  6. #6
    100 Club
    Join Date
    2008-08
    Location
    Vancouver, BC
    Posts
    105
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Still no ideas if it is possible to get the prompts?

  7. #7
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Actually, it's a bit more complex than that. In your code the following would give you the block definition object:
    Code:
    (setq BDef (tblsearch "BLOCK" (cdr (assoc 1 BORSS))))
    This list has a code -2 which contains the ename of the 1st internal entity inside the block. So then you need to step through each internal entity using entnext, checking for ATTDEF types and seeing if the tag is the same as that which you are currently viewing. (Compare DXF code 2's between the ATTRIB & ATTDEF, then the ATTDEF's code 3 is the prompt).

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Quote Originally Posted by Brian C View Post
    Still no ideas if it is possible to get the prompts?
    Try this code snip it's from my working routine
    Sorry no expalanation inside

    Code:
    (if
         (setq ent (entsel "\n  >>  Select block instance  >>"))
          (progn
     (setq en    (car ent)
           blk   en
           elist (entget en
           )
           )
     (if (zerop (cdr (assoc 66 elist)))
       (progn
         (princ "\n  >> Block has no attributes. Exit... <<")
         (exit)(princ)
         )
       )
     (setq bdef (tblobjname "BLOCK" (cdr (assoc 2 elist))))
     (while (setq bdef (entnext bdef))
       (if (= (cdr (assoc 0 (setq elist (entget bdef)))) "ATTDEF")
         (setq attlist (cons (cons
          (cdr (assoc 2 elist))
          (cdr (assoc 3 elist)))
        attlist)
        )
         )
       )
     (setq attlist (reverse attlist))
     (if attlist
       (progn
         (while (setq blk (entnext blk))
           (if (= (cdr (assoc 0 (setq elist (entget blk)))) "ATTRIB")
      (setq attdata (cons (cons
              (cdr (assoc 2 elist))
              (cdr (assoc 1 elist)))
            attdata)
            )
      )
           )
         (setq attdata (reverse attdata))
         (foreach item  attdata
           (if (setq found (assoc (car item) attlist))
      (setq result (cons (list (car item) (cdr found) (cdr item)) result)
            )
      )
           )
         (setq result (reverse result))
     
         (foreach lst  result
           (princ (strcat "\n  >> Tag: "
            (car lst)
            " >> Prompt: "
            (cadr lst)
            "  >>  Value: "
            (last lst))))
         )
       )
     )
          )
    ~'J'~

  9. #9
    100 Club
    Join Date
    2008-08
    Location
    Vancouver, BC
    Posts
    105
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Thanks Guys! I have it now, I really appreciate it!

    "J", I did a cut and paste of your code and it does what I want. Now I can rewrite mine to get exactly what I need - it is part of a larger attribute extraction lisp I am writing, and I did need the prompt.

  10. #10
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Block Attribute "Prompt" Text

    Quote Originally Posted by Brian C View Post
    Thanks Guys! I have it now, I really appreciate it!

    "J", I did a cut and paste of your code and it does what I want. Now I can rewrite mine to get exactly what I need - it is part of a larger attribute extraction lisp I am writing, and I did need the prompt.
    Glad if that helps
    Happy computing

    ~'J'~

Similar Threads

  1. Update "Prompt" tab in an existing Block Attribute.
    By joelnishan605002 in forum ARX
    Replies: 0
    Last Post: 2014-03-24, 09:04 PM
  2. Replies: 4
    Last Post: 2012-06-11, 05:23 PM
  3. How do I move "locked" attribute text in 2011?
    By thinkdesign_liesl in forum AutoCAD General
    Replies: 4
    Last Post: 2010-11-22, 12:50 PM
  4. if filter text equals "*" insert block "*"
    By d_m_hopper in forum AutoLISP
    Replies: 6
    Last Post: 2009-04-24, 05:46 PM
  5. Replies: 35
    Last Post: 2007-06-05, 10:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •