15 years ago
I am trying to get AutoCAD to display a .jpg file in either MS Photo
Editor or Windows Picture and Fax Viewer when I click on a text entity
which is the same as the photo name but I'm not having much luck.
I have several drawings, and each drawing has it's own folder for
photos. The routine below finds out which dwg I am in, then looks in the
Here is what I have so far. I realise that there is more code than
perhaps necessary, but this is for future expansion ie adding additional
file types like bmp.
(defun c:show_photo ()
(setq jpg_exists nil)
(setq ed (entget (car (entsel))))
(setq ent1 (assoc 1 ed))
(setq photoref (cdr ent1)) ;;the text value of the entity
(setq photoref_dwg_file_name (getvar "dwgname") ;; the dwg file name
photoref_dwg_file_base (vl-filename-base photoref_dwg_file_name)
;; the dwg file name minus extension
photo_files_folder (strcat photoref_dwg_file_base "_photos") ;;
the photo folder name
photoref_path (strcat "\"" "K:\\Network Info\\Network_Photos\\"
photo_files_folder "\\" photoref ".jpg" "\"");the spec for finding the
;;;note for above line: Startapp needs the file to open in quotes when a
space is used in the path.
;;;So the backslash quote attaches a literal quote at the back and the
front of the path
;;;note that this path is to be used for the startapp fuction.
;;;;;;sub to look for jpg and displays file
(defun do_jpg ()
(findfile photoref_path) (startapp "C:\\Program Files\\Common
Files\\Microsoft Shared\\PhotoEd.exe" photoref_path)
;_______________Sub for no photos found_________________
;(defun no_photos ()
;(setq no_photo (strcat "There are no photos found for photo reference:
;check for existence of files
(if (findfile photoref_path) (setq jpg_exists T)) ;check if jpg file
(if (not jpg_exists) (no_photos));if no photos exist do no_photos
The routine works if there is no photo for the text label clicked on,
but nothing seems to happen when there is a valid photo.
I first tried to use startapp to launch Windows and Fax Viewer, but this
seemed a bit more complicated as it is not a standalone program.
Seems I cant get Photo Editor to work either. I have a nearly identical
routine for opening pdf's with Acrobat Reader when I click on a text
entity, and this works fine, so can't see why this one doesn't work.
Any help would be greatly appreciated.