Hi,
I'm using some code I found on forums to detach unreferenced image from DWG files - however the code requires the user to say "yes" at a user prompt, which I can't have (I'll be cycling through thousands of files).
Can anyone help find a way to remove the user prompt? Here's the code I got from a forum:
(defun remlst (/ tmp1)
(setq
tmp (length (member (cdr (assoc 340 (entget delent))) enamelst))
)
(repeat (- (length symlst) tmp)
(setq tmp1 (cons (car symlst) tmp1))
(setq symlst (cdr symlst))
)
(setq tmp (list (car symlst)))
(setq symlst (append (reverse tmp1) (cdr symlst)))
)
(defun massoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)
(vl-load-com)
(setq ss1 (ssget "x" '((0 . "IMAGE"))))
(setq ctr 0)
(setq id (dictsearch (namedobjdict) "acad_image_dict"))
(setq symlst (massoc 3 id))
(setq enamelst (massoc 350 id))
(if ss1
(progn
(while (< ctr (sslength ss1))
(setq delent (ssname ss1 ctr))
(setq vl_delent (vlax-ename->vla-object delent))
(setq ipath (vla-get-ImageFile vl_delent))
(remlst)
(setq iname (strcat (vl-filename-base ipath) (vl-filename-extension ipath)))
(if (and (not (findfile ipath))
(not (findfile iname))
)
(progn
(dictremove (cdr (car id)) (car tmp))
(append tmp symlst)
(ssdel delent ss1)
(setq TextLine (strcat filepath filename " <---> " iname))
(write-line TextLine logfilename)
(vla-delete vl_delent)
)
(progn
(setq ctr (1+ ctr))
)
)
)
)
)
(while symlst
(dictremove (cdr (car id)) (car symlst))
(setq symlst (cdr symlst))
)
)
Since I had help on this matter a few years ago, I will post what I have.
;*** AUTOMATICALLY REMOVE ALL UNREFERENCED IMAGES *** 5-5-07 (if (and (setq dict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT")) (assoc 350 dict) );and (progn (setq lst nil) (if (setq ss1 (ssget "X" (list (cons 0 "IMAGE")))) (progn (princ "\n Removing Unreferenced Images.") (setq n 0) (repeat (sslength ss1) (setq lst (cons (cdr (assoc 340 (entget (ssname ss1 n)))) lst) n (1+ n)) );repeat );progn );if (setq n nil) (while (setq n (tblnext "BLOCK" (not n))) (setq ss1 (cdr (assoc -2 n))) (while ss1 (if (= (cdr (assoc 0 (setq elst (entget ss1)))) "IMAGE") (setq lst (cons (cdr (assoc 340 elst)) lst)) );if (setq ss1 (entnext ss1)) );while );while (foreach n dict (if (and (= (car n) 350) (not (member (cdr n) lst))) (entdel (cdr n)) );if );foreach );progn );if (setq dict nil ss1 nil n nil lst nil elst nil)
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.