write out xrefs and images to text file

Discussion in 'AutoCAD' started by The real JD, Jan 16, 2004.

  1. The real JD

    The real JD Guest

    Does anybody have a routine to do this? ie: filename.dwg generate
    filename.txt with xref list (and path) and image list (and path)? TIA
     
    The real JD, Jan 16, 2004
    #1
  2. The real JD

    Jeff Mishler Guest

    I have one I wrote in VBA to send Xref's to an Excel file. It wouldn'y
    be to much to add the images. Does it have to be a .txt file?

    Jeff
     
    Jeff Mishler, Jan 16, 2004
    #2
  3. The real JD

    The real JD Guest

    I'm not picky at this point! :)

     
    The real JD, Jan 16, 2004
    #3
  4. The real JD

    The real JD Guest

    I've got the following code to write out xrefs to a text file. Credit goes
    to Henry Francis for the original code... My question is, how do I add the
    drawing name in front of the xref list path? TIA

    IE:

    filename.dwg - C:\path\xrefname1.dwg
    filename.dwg - C:\path\xrefname2.dwg

    ============================
    (defun c:xreflist (/ blk_def blk_lst xrlst_in xrlst_out line_in ex_xr_lst
    tname)
    (setq tname (getvar "dwgname")
    tname (dos_strreplace tname ".dwg" "-xref.txt"))
    (setq blk_def (tblnext "block" T))
    (if (assoc 1 blk_def)
    (setq blk_lst (list (cdr (assoc 1 blk_def))))
    ) ;_ end of if
    (while (setq blk_def (tblnext "block"))
    (if (assoc 1 blk_def)
    (setq blk_lst (append (list (cdr (assoc 1 blk_def))) blk_lst))
    ) ;_ end of if
    ) ;_ end of while
    (if (setq xrlst_file (findfile (strcat (getvar "dwgprefix") tname)))
    (progn
    (setq xrlst_in (open xrlst_file "r"))
    (while (setq line_in (read-line xrlst_in))
    (if (not ex_xr_lst)
    (setq ex_xr_lst (list line_in))
    (setq ex_xr_lst (append (list line_in) ex_xr_lst))
    ) ;_ end of if
    ) ;_ end of while
    (close xrlst_in)
    ) ;_ end of progn
    ) ;_ end of if
    (progn
    (foreach n blk_lst
    (if (member n ex_xr_lst)
    nil
    (setq ex_xr_lst (append (list n) ex_xr_lst))
    ) ;_ end of if
    ) ;_ end of foreach
    (if ex_xr_lst
    (progn
    (setq ex_xr_lst (acad_strlsort ex_xr_lst))
    (setq xrlst_out (open (strcat (getvar "dwgprefix") tname) "w"))
    (foreach n ex_xr_lst
    (write-line n xrlst_out)
    ) ;_ end of foreach
    (close xrlst_out)
    ) ;_ end of progn
    ) ;_ end of if
    ) ;_ end of progn
    (mapcar
    '(lambda (x) (princ (strcat "\n" x)))
    blk_lst
    ) ;_ end of mapcar
    (princ)
    ) ;_ end of defun
     
    The real JD, Jan 16, 2004
    #4
  5. The real JD

    rdi Guest

    I don't remeber whether or not dwgprefix returns the the trailing backslash.
    Change the line (write-line n xrlst_out) to (write-line (strcat (getvar
    "dwgprefix") " - " (getvar "dwgname")))xrlst_out) if that doesn't work then
    go with (write-line (strcat (getvar "dwgprefix") "/ - " (getvar
    "dwgname")))xrlst_out)

    I'm pretty sure it'll be the first one though.

    HTH
     
    rdi, Jan 17, 2004
    #5
  6. The real JD

    The real JD Guest

    Thanks Jeff!
    I'll give it try and post results/comments in a day or so.
    Cheers!
     
    The real JD, Jan 19, 2004
    #6
  7. The real JD

    The real JD Guest

    i tried them. but I'm getting the following result:
    C:\dwgpath\ - dwgname.dwg
    C:\dwgpath\ - dwgname.dwg
    C:\dwgpath\ - dwgname.dwg
    C:\dwgpath\ - dwgname.dwg

    instead of
    dwgname - C:\xrefpath\xrefname1.dwg
    dwgname - C:\xrefpath\xrefname2.dwg
    dwgname - C:\xrefpath\xrefname3.dwg
    dwgname - C:\xrefpath\xrefname4.dwg
     
    The real JD, Jan 19, 2004
    #7
  8. The real JD

    The real JD Guest

    I figured it out!

    (write-line (strcat (getvar "dwgname") "," n) xrlst_out)

    Changed the "-" to a "," for importing into excel...

    Thanks for pointing me in the right direction!
     
    The real JD, Jan 19, 2004
    #8
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.