CapturePreviewImage : API to create the image from a AutoCAD document

By Virupaksha Aithal
The easy way to create an image from the drawing file is to use the “CapturePreviewImage” API of document. As this is an API of document, you need to open the drawing file in the editor to use this API.

[CommandMethod("CreateImage")]
static public void CreateImage()
{
    //zoom extents... need to use .NET 4.0 
    dynamic acad = Application.AcadApplication;
    acad.ZoomExtents();
 
    Document doc = Application.DocumentManager.MdiActiveDocument;
    using (Bitmap image = doc.CapturePreviewImage(376, 292))
    {
        //save the image...
        image.Save("c:\temp\test.png",
                    System.Drawing.Imaging.ImageFormat.Png);
    }
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading