Photo should open directly from the folder

Photo should open directly from the folder

sudarsann
Advocate Advocate
223 Views
3 Replies
Message 1 of 4

Photo should open directly from the folder

sudarsann
Advocate
Advocate

Hello

Request you, I want to open the image using AutoLISP command in AutoCAD. Image path is in autocad in text format.

When I select text in AutoCAD, the photo should open directly from the folder. I need lisp code.

 

sudarsann_0-1732091681982.png

 

0 Likes
Accepted solutions (1)
224 Views
3 Replies
Replies (3)
Message 2 of 4

komondormrex
Mentor
Mentor

hey,

(vla-addraster (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
			   (cdr (assoc 1 (entget (car (entsel "\nPick raster image path text: ")))))
			   (vlax-3d-point (getpoint "\nPick point to insert raster image: "))
			   1 
			   0
)
0 Likes
Message 3 of 4

sudarsann
Advocate
Advocate

With your code image is opening in AutoCAD window by clicking a point, but my requirement is directly open the image from windows explorer by selecting only the path in AutoCAD .

 

Thanks and Regards

Sudarsan

0 Likes
Message 4 of 4

paullimapa
Mentor
Mentor
Accepted solution

try this opnpng.lsp

 

; opnpng function selects text containing image file name to open
; OP:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/photo-should-open-directly-from-the-folder/m-p/13163091/highlight/false#M475062
(defun c:opnpng (/ en fil)
  (princ"\nPick Text Object...")
  (if(setq en (ssget  "_+.:E:S" '((0 .  "*TEXT"))))
    (if(findfile (setq fil (cdr(assoc 1 (entget (ssname en 0))))))
     (startapp "mspaint.exe" (strcat "\"" fil "\""))
     (alert(strcat "File Not Found: " fil))
    )
  )
  (princ)
)

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes