Author Topic: How to get the image list with lisp?  (Read 2413 times)

0 Members and 1 Guest are viewing this topic.

guohq

  • Newt
  • Posts: 84
How to get the image list with lisp?
« on: August 03, 2009, 12:33:15 PM »
How to get the image list with lisp whether the image is deleted or no!

guohq

  • Newt
  • Posts: 84
Re: How to get the image list with lisp?
« Reply #1 on: August 03, 2009, 12:39:42 PM »
(defun ImageLst ( / dicts  err imgdict num nn img rtn)
  (setq dicts (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
  (setq err (vl-catch-all-apply 'vla-item (list dicts "ACAD_IMAGE_DICT")))
  (if (vl-catch-all-error-p err)
    (setq rtn nil)
    (progn
      (setq imgdict (vla-item dicts "ACAD_IMAGE_DICT"))
      (setq num (vla-get-count imgdict) rtn'() nn 0)
      (repeat num
   (setq img (vla-item imgdict nn) nn (1+ nn))
   (setq rtn (cons img rtn))
   )
      )
    )
  )

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: How to get the image list with lisp?
« Reply #2 on: August 03, 2009, 12:47:23 PM »
Could be shortened:

Code: [Select]
(defun ImageLst (/ img lst)
  (vl-load-com)
  (if (vl-catch-all-error-p
        (setq img
          (vl-catch-all-apply 'vla-item
            (list
              (vla-get-dictionaries
                (vla-get-activedocument
                  (vlax-get-acad-object))) "ACAD_IMAGE_DICT")))) nil
    (vlax-for i img
      (setq lst (cons i lst))))
  lst)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.