Lisp modification (inserting images)

Lisp modification (inserting images)

BB8x
Advocate Advocate
2,206 Views
9 Replies
Message 1 of 10

Lisp modification (inserting images)

BB8x
Advocate
Advocate

Hi all

 

I am using 2 attached lisps. They insert multiple images into Autocad as a ref files. Attached files have random names. Is a chance to modify this lisps to insert images with their real name files?

 

Thanks

0 Likes
Accepted solutions (1)
2,207 Views
9 Replies
Replies (9)
Message 2 of 10

ronjonp
Advisor
Advisor
Accepted solution

Give this a try:

(defun c:img (/ ang dis ins lst spc o)
  (if (and (setq lst (lm:getfiles "Select Image Files to Insert" img:dir nil))
	   (setq ins (getpoint "\nSpecify insertion point: "))
      )
    (progn (initget 4)
	   (setq dis	 (cond ((getdist "\nSpecify image spacing <0>: "))
			       (0.0)
			 )
		 spc	 (vlax-get-property
			   (vla-get-activedocument (vlax-get-acad-object))
			   (if (= 1 (getvar 'cvport))
			     'paperspace
			     'modelspace
			   )
			 )
		 ang	 (angle '(0.0 0.0 0.0) (trans (getvar 'ucsxdir) 0 1))
		 img:dir (vl-filename-directory (car lst))
	   )
	   (foreach img	lst
	     (setq
	       ins (cons (+ (car ins)
			    dis
			    (vla-get-imagewidth (setq o (vlax-invoke spc 'addraster img ins 1.0 ang)))
			 )
			 (cdr ins)
		   )
	     )
	     ;; RJP - name of image to match filename
	     (vla-put-name o (vl-filename-base img))
	   )
    )
  )
  (princ)
)
(vl-load-com)
(princ)
0 Likes
Message 3 of 10

BB8x
Advocate
Advocate

Thanks mate for reply, but result is still the same

0 Likes
Message 4 of 10

ronjonp
Advisor
Advisor

@BB8x wrote:

Thanks mate for reply, but result is still the same


@BB8x  Strange .. works here:

 
 

2021-05-27_8-52-56.png

0 Likes
Message 5 of 10

BB8x
Advocate
Advocate

I tried many times from many directories same result. Does work. Mine is Autocad 2017

0 Likes
Message 6 of 10

BB8x
Advocate
Advocate
Edit: does not work
0 Likes
Message 7 of 10

ronjonp
Advisor
Advisor

Not sure what to say .. but I'm also running 2022.

0 Likes
Message 8 of 10

BB8x
Advocate
Advocate

Now I do not know what to say. After few days I tried again and it works. Have a feeling autocad needed computer reboot.

 

Thank you for this ronjonp

0 Likes
Message 9 of 10

ronjonp
Advisor
Advisor

@BB8x wrote:

Now I do not know what to say. After few days I tried again and it works. Have a feeling autocad needed computer reboot.

 

Thank you for this ronjonp


Glad to help 🍻

0 Likes
Message 10 of 10

BB8x
Advocate
Advocate

Bit odd. Usually works great, but from time to time works in old style with funny names. After autocad reboot proper names are in place

0 Likes