Hi,
I would suggest to use wblock to export each OLE images to a drawing and then attach the exported drawings as xrefs.
Please find the below code which will export each OLE images to a drawing file and then attach as xref.
Try this LISP on a test drawing as it will delete the OLE images.
Before running the lisp change the outputfolder in the code as per your system.
Click the +sign to see the Code
Spoiler (Highlight to read)
(defun C:OleExport ( / slctn cnt xrflist outfolder filename filepath path oldOSMode)
(vl-load-com)
(setq slctn (ssget "_x" (list '(0 . "OLE2FRAME"))));
(setq
xrflist '()
outfolder "C:\\Users\\username\\Desktop\\Xref\\ "
oldOSMode (getvar "OSMODE")
cnt 0
);setq
(setvar "FILEDIA" 0)
(setvar "OSMODE" 0)
(if slctn
(progn
(repeat (sslength slctn)
(setq filename (strcat "Xref-" (itoa cnt) ".dwg"))
(setq filepath (strcat outfolder filename))
(command "-WBLOCK" filepath "y" "" "0,0" (ssname slctn cnt) "")
;add the xrefpath to list
(setq xrflist (append (list filepath) xrflist))
(setq cnt ( + cnt 1))
);repeat
;Attach the exported drawings into the drawing
(foreach path xrflist
(command "-XREF" "A" path "0,0" "1" "1" "0")
);foreach
);progn
);if
(setvar "FILEDIA" 1)
(setvar "OSMODE" oldOSMode)
);defun
(defun C:OleExport ( / slctn cnt xrflist outfolder filename filepath path oldOSMode)
(vl-load-com)
(setq slctn (ssget "_x" (list '(0 . "OLE2FRAME"))));
(setq
xrflist '()
outfolder "C:\\Users\\username\\Desktop\\Xref\\"
oldOSMode (getvar "OSMODE")
cnt 0
);setq
(setvar "FILEDIA" 0)
(setvar "OSMODE" 0)
(if slctn
(progn
(repeat (sslength slctn)
(setq filename (strcat "Xref-" (itoa cnt) ".dwg"))
(setq filepath (strcat outfolder filename))
(command "-WBLOCK" filepath "y" "" "0,0" (ssname slctn cnt) "")
;add the xrefpath to list
(setq xrflist (append (list filepath) xrflist))
(setq cnt ( + cnt 1))
);repeat
;Attach the exported drawings into the drawing
(foreach path xrflist
(command "-XREF" "A" path "0,0" "1" "1" "0")
);foreach
);progn
);if
(setvar "FILEDIA" 1)
(setvar "OSMODE" oldOSMode)
);defun