write out xrefs and images to text file

  • Thread starter Thread starter The real JD
  • Start date Start date
T

The real JD

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
 
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
 
I'm not picky at this point! :-)

Jeff Mishler said:
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
 
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
 
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
 
Thanks Jeff!
I'll give it try and post results/comments in a day or so.
Cheers!
 
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
 
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!
 
Back
Top