How to get "vla-get-promptstring" in AttributeReference?

Discussion in 'AutoCAD' started by kht, Apr 13, 2004.

  1. kht

    kht Guest

    How to get "vla-get-promptstring" in AttributeReference?
     
    kht, Apr 13, 2004
    #1
  2. kht

    Joe Burke Guest

    Access the block definition in the blocks collection. Example:

    (defun c:ListPrompts ( / blocks ent vobj blkname blkdef lst )
    (setq blocks
    (vla-get-Blocks
    (vla-get-ActiveDocument
    (vlax-get-acad-object))))
    (setq ent (car (entsel "\nSelect block with attributes: ")))
    (setq vobj (vlax-ename->vla-object ent))
    (setq blkname (vlax-get vobj 'Name))
    (setq blkdef (vla-item blocks blkname))
    (vlax-for x blkdef
    (if (= "AcDbAttributeDefinition" (vlax-get x 'ObjectName))
    (setq lst (cons (vlax-get x 'PromptString) lst))
    )
    )
    lst
    ) ;end

    Command: listprompts
    Select block with attributes: ("Drawing No" "Section or Elevation Number")

    Joe Burke
     
    Joe Burke, Apr 13, 2004
    #2
  3. kht

    Joe Burke Guest

    Since this is an example, I ought to do it right. The vlax-for function should be as
    follows, rather than check ObjectName.

    (vlax-for x blkdef
    (if (vlax-property-available-p x 'PromptString)
    (setq lst (cons (vlax-get x 'PromptString) lst))
    )
    )

    Joe Burke
     
    Joe Burke, Apr 13, 2004
    #3
  4. Little different flavor with error checking.

    (defun c:listprompts2 (/ blocks util test vobj pnt blkname blkdef lst)
    (or *acadobj*
    (setq *acadobj* (vlax-get-acad-object)))
    (or *actdoc*
    (setq *actdoc* (vlax-get *acadobj* 'activedocument)))
    (setq blocks (vlax-get *actdoc* 'blocks)
    util (vlax-get *actdoc* 'utility)
    test (vl-catch-all-apply 'vla-getentity
    (list util 'vobj 'pnt "\nSelect block with attributes: ")))
    (if (not (vl-catch-all-error-p test))
    (progn
    (setq blkname (vlax-get vobj 'name))
    (setq blkdef (vla-item blocks blkname))
    (vlax-for x blkdef
    (if (vlax-property-available-p x 'promptstring)
    (setq lst (cons (vlax-get x 'promptstring) lst)))))
    (princ (strcat "\n" (vl-catch-all-error-message test))))
    lst
    )

    --
    Ken Alexander
    Acad2004
    Windows XP

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Apr 13, 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.