This bit of code will only removed unreferenced images in the drawing file
and not in any other "attached" files - xref or otherwise.
;*** REMOVE UNREFERENCED IMAGES *** 5-5-07
; Erasing images does not unload images from file.
(defun QSAVE_IMAGE ( / a b c n n1 s )
(if (and (setq a (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
(assoc 350 a) );and
(progn
(setq b nil)
(if (setq s (ssget "X" (list (cons 0 "IMAGE"))))
(progn
(setq n 0)
(repeat (sslength s)
(setq b (cons (cdr (assoc 340 (entget (ssname s n)))) b) n (1+ n))
);repeat
);progn
);if
(setq n nil)
(while (setq n (tblnext "BLOCK" (not n)))
(setq s (cdr (assoc -2 n)))
(while s
(if (= (cdr (assoc 0 (setq c (entget s)))) "IMAGE")
(setq b (cons (cdr (assoc 340 c)) b)) );if
(setq s (entnext s))
);while
);while
(setq n1 0)
(foreach x a
(if (and (= (car x) 350) (not (member (cdr x) b)))
(progn (entdel (cdr x)) (setq n1 (1+ n1)) ));if
);foreach
(if (> n1 0) (princ "\n Removing Unreferenced Image(s)."))
);progn
);if
(setq a nil b nil c nil n nil n1 nil s nil)
);endQSAVE_IMAGE
???
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.