Author Topic: Finding images nested within an xref  (Read 1413 times)

0 Members and 1 Guest are viewing this topic.

cadpoobah

  • Newt
  • Posts: 48
Finding images nested within an xref
« on: March 27, 2017, 01:43:08 PM »
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!
« Last Edit: March 27, 2017, 01:46:31 PM by cadpoobah »
Chris Lindner
Onebutton CAD Solutions
----------------------------------------------------
www.onebuttoncad.com #dayjob
www.unpavedart.com    #sidehustle

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Finding images nested within an xref
« Reply #1 on: March 27, 2017, 02:33:17 PM »
Maybe:
Code - Auto/Visual Lisp: [Select]
  1. (defun _images (/ out)
  2.     (vlax-for y x
  3.       (if (= "AcDbRasterImage" (vla-get-objectname y))
  4.         ;; List as block name containing image, image name, image path
  5.         (setq out (cons (list (vla-get-name x) (vla-get-name y) (vla-get-imagefile y)) out))
  6.       )
  7.     )
  8.   )
  9.   out
  10. )
  11. (_images)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadpoobah

  • Newt
  • Posts: 48
Re: Finding images nested within an xref
« Reply #2 on: March 27, 2017, 02:45:18 PM »
Maybe:
Code - Auto/Visual Lisp: [Select]
  1. (defun _images (/ out)
  2.     (vlax-for y x
  3.       (if (= "AcDbRasterImage" (vla-get-objectname y))
  4.         ;; List as block name containing image, image name, image path
  5.         (setq out (cons (list (vla-get-name x) (vla-get-name y) (vla-get-imagefile y)) out))
  6.       )
  7.     )
  8.   )
  9.   out
  10. )
  11. (_images)

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!
Chris Lindner
Onebutton CAD Solutions
----------------------------------------------------
www.onebuttoncad.com #dayjob
www.unpavedart.com    #sidehustle

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Finding images nested within an xref
« Reply #3 on: March 27, 2017, 03:03:06 PM »
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC