System Variable as an Block Attribute?

Discussion in 'AutoCAD' started by jmurchison, Jun 9, 2004.

  1. jmurchison

    jmurchison Guest

    Is there a way to put a system variable into an attributed block? I am trying to put the last modified variable (tdupdate) into the title block as an attribute so I can later extract it into an excel document. Right now I can get the information into the title block but can not extract it b/c it is rtext.

    Thanks for any help!
     
    jmurchison, Jun 9, 2004
    #1
  2. Yes! You can create block with an Invisible Attribute and no linework. This
    makes the block difficult to erase accidentally by selection unless someone
    selects "ALL". I do this with a saved drawing scale. I rewrote my program
    and have NOT tested this code (so there might be a type or 2).

    Example to get attribute -
    (defun GetAttrib (/ SS EG AT)
    (setq SS (ssget "X" (list (cons 2 "InvisibleBlockName"))))
    (if SS
    (progn
    (setq EG (entget (ssnamee SS 0)))
    (setq AT (entget (entnext (cdr (assoc -1 EG)))))
    (setq AV (cdr (assoc 1 AT)))
    )
    (princ "\nERROR - InvisibleBlockName not in drawing.")
    )
    (princ)
    )

    Example to add or change attribute -
    (defun SetAttrib (/ SS EG AT)
    (setq TV (getvar "tdupdate"))
    (setq SS (ssget "X" (list (cons 2 "InvisibleBlockName"))))
    (if SS
    (progn ;modify existing block
    (setq EG (entget (ssnamee SS 0)))
    (setq AT (entget (entnext (cdr (assoc -1 EG)))))
    (setq AT (subst (cons 1 (rtos TV 2 10)) (assoc 1 AT) AT))
    (entmod AT)
    )
    (progn ;insert new block
    (command "INSERT" "InvisibleBlockName" P0 1 1 0 (rtos TV 2 10))
    )
    )
    (princ)
    )
     
    Alan Henderson @ A'cad Solutions, Jun 9, 2004
    #2
  3. jmurchison

    Doug Broad Guest

    If you have 2005, then insert a field into the attribute.
    It will become the attribute value when inserted. Fields
    are refreshed during regens.


    the title block as an attribute so I can later extract it into an excel document. Right now I can get the information into the title
    block but can not extract it b/c it is rtext.
     
    Doug Broad, Jun 9, 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.