Page 1 of 1

drawing rectangles on dwg image

Posted: 27 Mar 2009, 00:56
by DataMike
I am trying to load a dwg image, draw rectangles on it, and save it with cadimport.dll in asp.net.
cadImage = CADImage.CreateImageByExtension(imagePath);
cadImage.LoadFromFile(imagePath);
cadImage.Draw(graphics, rectangleF); << is not working for me.
I need to be able to draw the rectangles on an existing cadimage. Perhaps I am way off, I need to be pointed in the right direction. Please help.
Thank you.

Re: drawing rectangles on dwg image

Posted: 27 Mar 2009, 09:00
by support
Hello!

We recommend to use the following code:

Code: Select all

private void btnAddPolyline_Click(object sender, System.EventArgs e)
{
	if(this.cadImage == null) 
	{
		this.cadImage = new CADImage();
		this.cadImage.InitialNewImage();
		this.cadImage.UseBufMetafile = false;
	}
	else
		this.cadImage.UseBufMetafile = false;

	CADPolyLine entPoly = new CADPolyLine();
	entPoly.Closed = true;
	entPoly.Color = CADConst.clNone;

	CADVertex entVertex = new CADVertex(); 
	entPoly.AddEntity(entVertex);
	entVertex.Point = new DPoint(0,0,0);			

	entVertex = new CADVertex();
	entPoly.AddEntity(entVertex);
	entVertex.Point = new DPoint(0,100,0);

	entVertex = new CADVertex(); 
	entPoly.AddEntity(entVertex);
	entVertex.Point = new DPoint(200,100,0);

	entVertex = new CADVertex(); 
	entPoly.AddEntity(entVertex);
	entVertex.Point = new DPoint(200,0,0);

	this.cadImage.Converter.OnCreate(entPoly);
	this.cadImage.Converter.Loads(entPoly);
	this.cadImage.Converter.Entities.Add(entPoly);

	this.cadImage.GetExtents();
	this.DoResize();	
	SaveAsDXF(@"c:\Rectangle.dxf");
}
Sergey.