Solved! Go to Solution.
Solved by Lisa_Pohlmeyer. Go to Solution.
@LisaPohlmeyer wrote:
I searched the groups and the closest discussion I could find was here but there didn't seem to be a clear cut solution. http://forums.autodesk.com/t5/NET/How-to-programmatically-find-all-references-xref-dwg-jpg-pdf-OLE/m... I have a jpg file that I needed to apply some transparency to and saved it as a png file. I now want to delete the jpg file from the folder but it's being referenced in several drawings, and I don't know which ones. Is there a way to reverse the function of Reference Manager (perhaps with a different app), ie find all the drawing files that reference my jpg file?
Lisa,
for what I understood, you need to know if a particular image is referenced in the dwg's...
A quick one, to "scan" a directory of dwg's searching for that image, and if finds the image, create one txt file with the dwg names.
Before running the code:
Open a new dwg and ensures that all dwg's to be scanned are closed.
;; Load Supporting Functions ;; Old Version of 'BrowseForFolder' by: Tony Tanzillo (defun BrowseForFolder (Message / sh folder parentfolder folderobject result) (vl-load-com) (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ) ) (setq folder (vlax-invoke-method sh 'BrowseForFolder 0 Message 0) ) (vlax-release-object sh) (if folder (progn (setq parentfolder (vlax-get-property folder 'ParentFolder) ) (setq FolderObject (vlax-invoke-method ParentFolder 'ParseName (vlax-get-property Folder 'Title) ) ) (setq result (vlax-get-property FolderObject 'Path) ) (mapcar 'vlax-release-object (list folder parentfolder folderobject) ) (if (/= (substr result (strlen result)) "\\") (setq result (strcat result "\\")) result ) ) ) );; defun ;;; Scan a directory of dwg's to find out if the selected image file is referenced, ;;; and creates a txt file with the dwg names. ;;; hms - 12-31-2013 (defun c:FindImg (/ CADVER DBX DIRPATH DWGFILE DWGLIST ID IMAGE INAME LYT OFILE TXTFILE) (if (and (setq DirPath (BrowseForFolder "Select directory to scan drawings.")) (setq IName (getfiled "Select the Image to Search: " "" "jpg;png;tif;bmp;gif" 8)) );; and (progn (setq DwgList (vl-directory-files DirPath "*.dwg" 1) TxtFile (strcat DirPath (vl-filename-base IName) (vl-filename-extension IName) ".txt") CadVer (substr (getvar "acadver") 1 2) Id (strcat "objectdbx.AxDbDocument." CadVer) );; setq (foreach Dwg DwgList (setq DwgFile (strcat DirPath Dwg) Dbx (vlax-create-object Id) );; setq (vla-open Dbx DwgFile) (vlax-for lyt (vla-get-Layouts Dbx) (vlax-for blk (vla-get-Block lyt) (if (and (= (vla-get-ObjectName blk) "AcDbRasterImage") (= (setq image (vla-get-ImageFile blk)) IName) );; and (progn (setq OFile (open TxtFile "a")) (write-line DwgFile OFile) (close OFile) );; progn );; if );; vlax-for );; vlax-for (vlax-release-object Dbx) (princ) );; foreach );; progn );; if (princ "\n...Done!...") (princ) );; FindImg
HTH
Henrique