Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding all jpg references in drawings

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Lisa_Pohlmeyer
641 Views, 3 Replies

Finding all jpg references in drawings

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 Pohlmeyer
Civil 3D User
Website | Facebook | Twitter

Tags (3)
3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: Lisa_Pohlmeyer


@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

EESignature

Message 3 of 4

To add a little more detail: The image is from ONE network location (it's a Highway sign that gets used on several projects). So, the drawings that it is used in are also in several different project folders. The BatchInDatabase 1.1 from the Exchange looks promising. Since I'm searching the entire network, there's 4614 files to search. We'll see.


Lisa Pohlmeyer
Civil 3D User
Website | Facebook | Twitter

Message 4 of 4

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost