(defun C:eie ( / slctn cnt xrflist outfolder filename filepath path oldOSMode)
(vl-load-com)
(setq slctn (ssget "_x" (list '(0 . "OLE2FRAME"))));
(setq
xrflist '()
outfolder (getvar 'DwgPrefix)
oldOSMode (getvar "OSMODE")
cnt 0
);setq
(setvar "FILEDIA" 0)
(setvar "OSMODE" 0)

(if slctn
(progn
(repeat (sslength slctn)
(setq filename (strcat "OLE Image 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" "O" path "0,0,0" "1" "1" "0")
);foreach
);progn
);if
(setvar "FILEDIA" 1)
(setvar "OSMODE" oldOSMode)
);defun

(c:eie)

Advertisements