;;;Program to find the name and path of models attached to drawing files,
;;; and write them to a text file in the current drawing directory

;;;By Igal Averbuh - Topaz LTD 2014

(defun c:xrep (/ cur_dwgname cur_dwgname_len dwgno
csv_name block_table bpath b
CD CS YR MN DY
HR MI MO DT
)
(setq cur_dwgname (getvar "dwgname"))
(setq cur_dwgname_len (- (strlen cur_dwgname) 4))
(setq dwgno (substr cur_dwgname 1 cur_dwgname_len))

(setq csv_name (strcat dwgno"_""ATTACHED_XREFs.txt"))

(setq CD (getvar "CDATE")
CS (rtos CD 2 8)
YR (substr CS 1 4)
MN (substr CS 5 2)
DY (substr CS 7 2)
HR (substr CS 10 2)
MI (substr CS 12 2)
)
(cond
((= MN "01")(setq MO "Jan"))
((= MN "02")(setq MO "Feb"))
((= MN "03")(setq MO "Mar"))
((= MN "04")(setq MO "Apr"))
((= MN "05")(setq MO "May"))
((= MN "06")(setq MO "June"))
((= MN "07")(setq MO "July"))
((= MN "08")(setq MO "Aug"))
((= MN "09")(setq MO "Sept"))
((= MN "10")(setq MO "Oct"))
((= MN "11")(setq MO "Nov"))
((= MN "12")(setq MO "Dec"))
(t)
)
(setq DT (strcat "FILE NAME: "(getvar "DWGPREFIX") (getvar "DWGname")",Created By: "(getvar "LOGINNAME")",DATE: " YR " " MO " " DY " - " HR":"MI))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq b (OPEN (strcat (getvar "dwgprefix")csv_name) "a"))
(write-line DT b)
(write-line "" b)
(write-line (strcat "Xrefs Names:") b)
(write-line "" b)
(CLOSE b)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq block_table(tblnext "block" t))
(While (/= block_table nil)
(setq bpath(cdr(assoc 1 block_table)))
(if (/= bpath nil)
(progn
(setq b (OPEN (strcat (getvar "dwgprefix")csv_name) "a"))
(write-line (strcat (cdr (assoc 2 block_table))) b)
(CLOSE b)
)
)
(setq block_table(tblnext "block"))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq b (OPEN (strcat (getvar "dwgprefix")csv_name) "a"))
; (write-line DT b)
(write-line "" b)
(write-line (strcat "Xrefs Paths:") b)
(write-line "" b)
(CLOSE b)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq block_table(tblnext "block" t))
(While (/= block_table nil)
(setq bpath(cdr(assoc 1 block_table)))
(if (/= bpath nil)
(progn
(setq b (OPEN (strcat (getvar "dwgprefix")csv_name) "a"))
(write-line (strcat bpath) b)
(CLOSE b)
)
)
(setq block_table(tblnext "block"))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(alert "Xref Report placed in current drawing directory")
)
(c:xrep)

Advertisements