(defun c:PXI ( / GetXrefs XrList Opened Data Path )

(defun GetXrefs (/ tempData tempEnt XrefList)

(while (setq tempData (tblnext "block" (not tempData)))
(if (equal (logand (cdr (assoc 70 tempData)) 4) 4)
(progn
(setq tempEnt (tblobjname "block" (cdr (assoc 2 tempData))))
(setq tempData (entget (cdr (assoc 330 (entget tempEnt)))))
(setq XrefList
(cons
(cons
tempEnt
(
(lambda ( x / InsList NestList )
(foreach i x
(cond
((equal (car i) 331)
(setq InsList (cons (cdr i) InsList))
)
((equal (car i) 332)
(setq NestList (cons (cdr i) NestList))
)
)
)
(list InsList NestList)
)
(member '(102 . "{BLKREFS") tempData)
)
)
XrefList
)
)
)
)
)
XrefList
)
;-----------------------------------------------------
(if (setq XrList (GetXrefs))
(progn
(setq Opened (open (setq Path (strcat (getvar 'DwgPrefix) (vl-filename-base (getvar 'DwgName)) "_Xref.txt")) "w"))
(foreach i XrList
(setq Data (entget (car i)))
(write-line (strcat "Xref name: " (cdr (assoc 2 Data))) Opened)
(write-line (strcat "\tSaved path: " (cdr (assoc 1 Data))) Opened)
(write-line (strcat "\tFound at path: " (findfile (cdr (assoc 1 Data)))) Opened)
(write-line "\tInserted at:" Opened)
(foreach j (cadr i)
(setq Data (entget j))
(write-line (strcat "\t\tLayout: " (cdr (assoc 410 Data))) Opened)
(write-line (strcat "\t\tInsertion point: " (vl-princ-to-string (cdr (assoc 10 Data)))) Opened)
(write-line (strcat "\t\tScale[X Y Z]: " (rtos (cdr (assoc 41 Data))) " " (rtos (cdr (assoc 42 Data))) " " (rtos (cdr (assoc 43 Data)))) Opened)
(write-line (strcat "\t\tRotation: " (rtos (cdr (assoc 50 Data)))) Opened)
(write-line (strcat "\t\tLayer: " (cdr (assoc 8 Data))) Opened)
)
(write-line "\tNested xrefs:" Opened)
(foreach j (caddr i)
(write-line (strcat "\t\t" (cdr (assoc 2 (entget j)))) Opened)
)
)
(close Opened)
(startapp "notepad.exe" Path)
(prompt (strcat "\n Report at: " Path))

)
(prompt "\n No xrefs within drawing.")
)
(princ)
)
(c:pxi)

Advertisements