Code Red > AutoLISP (Vanilla / Visual)
Finding images nested within an xref
(1/1)
cadpoobah:
All,
I would like to find a way to determine if a particular xref has any images attached (nested) to it and return a list of their names and paths. (Bonus points if it can tell me whether the image is loaded or unloaded!)
It seems easy enough to do if the image is directly attached to the current drawing, but the nesting scenario is giving me fits.
Any takers?
Thanks!
ronjonp:
Maybe:
--- Code - Auto/Visual Lisp: ---(defun _images (/ out) (vlax-for x (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for y x (if (= "AcDbRasterImage" (vla-get-objectname y)) ;; List as block name containing image, image name, image path (setq out (cons (list (vla-get-name x) (vla-get-name y) (vla-get-imagefile y)) out)) ) ) ) out)(_images)
cadpoobah:
--- Quote from: ronjonp on March 27, 2017, 02:33:17 PM ---Maybe:
--- Code - Auto/Visual Lisp: ---(defun _images (/ out) (vlax-for x (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for y x (if (= "AcDbRasterImage" (vla-get-objectname y)) ;; List as block name containing image, image name, image path (setq out (cons (list (vla-get-name x) (vla-get-name y) (vla-get-imagefile y)) out)) ) ) ) out)(_images)
--- End quote ---
Very nice, @ronjonp!
I just found this post that uses ObjectDBX. I tweaked it to get the name & path of loaded images. It's a tad bit quicker than your code simply because yours is having to work harder, but yours works regardless of whether the xref file is open or not.
Thanks!
ronjonp:
Glad to help :)
Navigation
[0] Message Index
Go to full version