60000079 Export Drawing to BMP

Article 60000079
Type HowTo
Product Engine
Version 6
Date Added 3/15/2007
Fixed (3/15/2007)
Submitted by Raymond Toh

Summary

I cannot find any samples which can show me how to export a drawing to BMP. I found a method rendertographics but do not know how to use it. In previous version ( version 5.0 ), I did it successfully, but the method used seems totally changed.

Solution

In a new project add a vdFramedControl, a picturebox  (this is optional) and a button and a code like :

VdFramedControl1.BaseControl.ActiveDocument.Open("C:\temp\EXAMPLE.dxf")
VdFramedControl1.BaseControl.ActiveDocument.CommandAction.CmdSelect(
"ALL")
Dim selset As VectorDraw.Professional.vdCollections.vdSelection
selset = VdFramedControl1.BaseControl.ActiveDocument.Selections.FindName(
"VDRAW_PREVIOUS_SELSET")
Dim a As VectorDraw.Geometry.Box|
a = selset.GetBoundingBox
PictureBox1.Width = 200 ' exported image will be 200x200 pixels
PictureBox1.Height = 200
Dim img1 As Image
img1 =
New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim graph As System.Drawing.Graphics
graph = Graphics.FromImage(img1)
a.TransformBy(VdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.World2ViewMatrix)

VdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.RenderToGraphics(graph, a, img1.Width, img1.Height)
img1.Save("C:\_temp\aaaaa.bmp", System.Drawing.Imaging.ImageFormat.Bmp) 'save to disk
PictureBox1.Image = img1 ' show in form's Picture box

Send comments on this topic.