I'm trying to "transform" an autocad drawing into an image format file, but I only can get the image that is in the main window, never the whole drawing. Anybody can help me how to get the whole drawing and convert it to an image format file.
Thanks and kind regards,
Yes that is really what i want, but I want to do it programmatically. I want to raster the whole drawing to an image like jpeg or a png image. Do you have any ideas how can I accomplish that?
I can see two options:
1. Programatically zoom-extents your drawing and take a screenshot as per the ScreenShot plugin; or
2. Programatically plot the drawing to an image format as suggested by Gaston.
I would go for option 2 as you will have full control over the resolution of the raster image produced.
To get you started, the following lists a bunch of posts for programatically plotting in AutoCAD:
Searching these forums and I'm sure you'll find something that suits.
Hope this helps.
First of all thanks for all the answers, I've been searching in that blog that you mentioned and it always creates a dwf file, what I want is a jpeg or a png file, I think maybe it has something to do with the configuration used like this:
psv.SetPlotConfigurationName(ps, "DWF6 ePlot.pc3", "ANSI_A_(8.50_x_11.00_Inches)");
Because when it calls the function to generate the output file:
pe.BeginDocument( pi, doc.Name, null, 1, true, "c:\\test-output");
This will create test-output.dwf file, maybe this has something to do with that option DWF6 ePlot.pc3
Is there any configuration for jpeg or png file?
Yes DWF6 ePlot.pc3 will plot to *.dwf. To see what other plot configurations are available on your system check the plot dialog in AutoCAD. For *.jpg try using PublishToWeb JPG.pc3 and for *,png try using PublishToWeb PNG.pc3.
Yes that was it, once I used
acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG to PDF.pc3", "ANSI_A_(8.50_x_11.00_Inches)");
It creates a pdf file.
Thanks a lot,
Public Shared Sub GenerarImagenExterna(ByVal archivoDWG As String, ByVal tamaino As Drawing.Size) Dim imagen As Drawing.Bitmap Dim acadDoc As Document Dim acadDocs As DocumentCollection acadDocs = Application.DocumentManager acadDoc = acadDocs.Open(archivoDWG, forReadOnly:=False) imagen = acadDoc.CapturePreviewImage(width:=CType(tamaino.W
idth, UInteger), height:=CType(tamaino.Height, UInteger)) acadDoc.CloseAndDiscard() imagen.Save(IO.Path.ChangeExtension(archivoDWG, ".png")) End Sub