pulling out a value in a attribute

Discussion in 'AutoCAD' started by mosness, Dec 3, 2004.

  1. mosness

    mosness Guest

    In my title block I have the scale 1/4"=1'-0" in a attribute along with others. Can anyone tell me how I can pull out the scale value from the attribute when I have multiple attribute in my title block.
     
    mosness, Dec 3, 2004
    #1
  2. mosness

    John Uhden Guest

    One would hope that each attribute has a unique tag to help you identify it.




    others. Can anyone tell me how I can pull out the scale value from the
    attribute when I have multiple attribute in my title block.
     
    John Uhden, Dec 4, 2004
    #2
  3. mosness

    ECCAD Guest

    Here is a sample. Uncomment the (prompt .. lines to see
    what it found..

    ;; GET_ATTR_VAL.LSP
    ;; Return value of Insert [block] attribute, by tagname
    (setvar "CMDECHO" 0)
    ;;
    ;; DXF Function
    ;;
    (defun dxf (code elist)
    (cdr (assoc code elist))
    ); end function dxf
    ;; Function to Get Attribute Value
    ;;
    ;; Call: (gav "block_name" "attribute_tag")
    ;;
    (defun gav ( blockname attrtagname / SS ent atr en ex tag_name )
    (setq SS (ssget "X" (list (cons 2 blockname))))
    (if (= SS nil)
    (prompt (strcat "\nCould not find Blockname " blockname))
    ); end if
    (if (/= SS nil); must be a block by that name
    (progn
    (setq ent (entget (ssname ss 0)))
    (if (and
    (= "INSERT" (cdr (assoc 0 ent))); case of BLOCKS
    (/= (cdr (assoc 66 ent)) nil)); with Attrib's following
    (progn
    (setq en (entget (entnext (dxf -1 ent))))
    (if (/= en nil)
    (progn
    (setq atr nil val nil)
    (setq atr (cdr (assoc 0 en)))
    (while (/= "SEQEND" (cdr (assoc 0 en)))
    (setq ex (entget (entnext (dxf -1 en))))
    (setq atr nil)
    (setq atr (cdr (assoc 0 ex)))
    (if (= "ATTRIB" atr); case of attributes
    (progn
    (setq tag_name (strcase (cdr (assoc 2 en))))
    ;;;(prompt (strcat "\nTag=" tag_name " Value=" (cdr (assoc 1 en))))
    (if (= tag_name (strcase attrtagname)); this is the one
    (setq val (cdr (assoc 1 en))); get Attr Value
    ); end if
    ); end progn
    ); end if
    (setq en ex); swap next entity
    ); end while
    ); end progn
    ); end if
    ); end progn
    ); end if
    (if val
    (progn
    ;;; (prompt (strcat "\nFound " val " in Attribute Tag " attrtagname "\n"))
    val
    ); end progn
    ); end if
    ); end progn
    ); end if
    ); function
    (princ)

    Bob
     
    ECCAD, Dec 4, 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.