EXTRACT EMBEDDED IMAGES FROM autocad drawing

EXTRACT EMBEDDED IMAGES FROM autocad drawing

danglar
Advocate Advocate
6,190 Views
5 Replies
Message 1 of 6

EXTRACT EMBEDDED IMAGES FROM autocad drawing

danglar
Advocate
Advocate

Hi All!

I receved a huge file with a bunch of embedded images and I need to convert them all to external images attached to drawing in a same place...

Is it possible to do it via lisp or manualy?

0 Likes
6,191 Views
5 Replies
Replies (5)
Message 2 of 6

Ajilal.Vijayan
Advisor
Advisor

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
 
(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

 

0 Likes
Message 3 of 6

danglar
Advocate
Advocate

Thank you for your help Ajilal.Vijayan!

Code works perfect! I even make some changes in your code (see attached lsp file), but I still have a problem with this “OLE Xref”

When I rotate this xref OLE Image disappear and I see OLE Frame only

Can you suggest to do some in order to solve this problem?

0 Likes
Message 4 of 6

Ajilal.Vijayan
Advisor
Advisor

Hi,

Unfortunately OLE objects does not provide much editing operations and rotate is one of them.

Rotating OLE objects.

 

One another option is to create code to export each OLE object as *.bmp files.

But the problem is, as the export option depends on document view, the exported image may need to scale,crop.

And to insert back in the drawing as xref have to fix the location as well.

 

Message 5 of 6

danglar
Advocate
Advocate

Thank you for your answer. Is it possible to create own views for each one of ole images i order to make this view current before you started to export images as BMP files? You have coordinates of four corners of each one of OLE images but all that you need is only two of them...

0 Likes
Message 6 of 6

murtada_f
Community Visitor
Community Visitor

You can use "OLEOPNE" to open images in the default editor, and then save it as a separate file.

Now you can insert it as xref.