update attribute with filename

Discussion in 'AutoCAD' started by jclaidler, May 14, 2004.

  1. jclaidler

    jclaidler Guest

    Using lisp, what would be the best way to update an attribute value to the filename ??
     
    jclaidler, May 14, 2004
    #1
  2. jclaidler

    ECCAD Guest

    ;;
    ;; Define DXF function
    ;;
    (defun dxf (code elist)
    (cdr (assoc code elist))
    ); end function dxf
    ;;
    ;; Local Function to modify entities (using entmod)
    ;;
    (defun emod ()
    (if (and (/= ent nil)(/= ostr nil)(/= nstr nil))
    (entmod (setq ent (subst (cons 1 nstr)(cons 1 ostr) ent)))
    ); end if
    (princ)
    ); end function emod
    ;;
    ;; Get the drawing name..
    (setq dwgname (strcat (getvar "dwgprefix") "\\" (getvar "dwgname")))
    (prompt "\nPick the Attributed Block:")
    (setq ss (ssget))
    (if ss
    (progn
    (setq D (ssname ss 0)) ; get 1st item in ss
    (setq ent (entget D)) ; entity
    (setq ip (cdr (assoc 10 ent))) ; get insertion point
    (setq ostr "")
    (setq ent (entget (entnext (dxf -1 ent)))); extract attrib
    (setq ostr (cdr (assoc 1 ent))) ; pick old Atr Value
    (setq nstr dwgname) ; new Drawing name
    (emod) ; change entity
    ); end progn
    ); end if
    (princ)
     
    ECCAD, May 14, 2004
    #2
  3. jclaidler

    jclaidler Guest

    Where in this program is the attribute tag ??
    What tag is this program updating ?

    thanks
     
    jclaidler, May 14, 2004
    #3
  4. jclaidler

    ECCAD Guest

    Is the attribute your updating - burried in a Title-Block - not the first attribute ? If so, you need to loop through the attributes, and check for a tag name, then send that to emod. Is a little different. In this program, the 'entity' is variable 'ent', which is obtained from 'd', which is 1st entity in 'ss'.
    If you want to search for the attribute tag, let me know, I can revise program to loop and find it.

    Bob
     
    ECCAD, May 14, 2004
    #4
  5. jclaidler

    jclaidler Guest

    yes, I need to search for a attribute tag.
    I am creating a program to update all of our drawings, and want the drawing name to be filled out automatically in the title block. The tag is "Drawing_No".

    Thanks for your help.
     
    jclaidler, May 14, 2004
    #5
  6. jclaidler

    ECCAD Guest

    If the dwgname is not what you wanted, edit the line..
    (setq dwgname (strcat (getvar "dwgprefix") (getvar "dwgname")))
    ..to be
    (setq dwgname (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname") 4)))))
    ........
    Bob
     
    ECCAD, May 14, 2004
    #6
  7. jclaidler

    ECCAD Guest

    IF it doesn't find the attribute. "Drawing_No", change this to:
    "DRAWING_NO".
    Bob
     
    ECCAD, May 14, 2004
    #7
  8. Why not replace the attribute with RTEXT or a FIELD object?
     
    Allen Johnson, May 14, 2004
    #8
  9. jclaidler

    jclaidler Guest

    Because our customers want attributes, plus they don't have AutoCAD 2005 yet.
     
    jclaidler, May 14, 2004
    #9
  10. jclaidler

    John Coon Guest

    What about adding a reactor in the title block

    John coon
    yet.
     
    John Coon, May 15, 2004
    #10
  11. jclaidler

    jclaidler Guest

    Can you supply an example of this ??

    Thanks.
     
    jclaidler, May 17, 2004
    #11
  12. jclaidler

    tsigwing Guest

    Try using RTEXT
     
    tsigwing, May 17, 2004
    #12
  13. jclaidler

    john coon Guest

    I posted a rtext sample in customer files. you can also go to the express
    tools & select help (enter rtext)

    John Coon
     
    john coon, May 18, 2004
    #13
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.