Page 1 of 1

Add Hatch to Ellipse

Posted: 05 Dec 2008, 07:20
by Anderson
Hello,

I have a .dxf file just contain 1 ellipse entity.
how can i add hatch on it ?

Re: Add Hatch to Ellipse

Posted: 05 Dec 2008, 12:40
by support
Hello!

Please try the following code (based on Viewer demo):

Code: Select all

		private void btnAddHatchOnEllipsePoints_Click(object sender, System.EventArgs e)
		{
			if(this.cadImage == null)
			{
				this.cadImage = new CADImage();
				this.cadImage.InitialNewImage();
				this.cadImage.UseDoubleBuffering = false;
			}
			this.cadImage.UseDoubleBuffering = false;
			int entCount = this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);

			for(int i=0;i<entCount;i++)
			{
				if(this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i] is
					CADEllipse)
				{
					CADEllipse entEllipse =
						(CADEllipse)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];

					CADHatch Hatch = new CADHatch();

					Hatch.HatchName = "ANSI31";					
					CAD2DBoundaryList v2DBList = new CAD2DBoundaryList();
					v2DBList.BoundaryType = 7;// Polyline type
					Hatch.BoundaryData.Add(v2DBList);
					CAD2DPolyline v2DPolyline = new CAD2DPolyline();
					v2DBList.Add(v2DPolyline);

					CAD2DPoint ent2DPoint;
					DPoint Point;
					for(int j=0;j<entEllipse.PolyPoints.Count;j++)
					{
						Point = (DPoint)entEllipse.PolyPoints[j];
						ent2DPoint = new CAD2DPoint(Point.X,Point.Y);
						v2DPolyline.Vertexes.Add(ent2DPoint); 
					}

					v2DPolyline.Closed = true;

					Hatch.Color = Color.Azure;
					HatchPatternData vHPData = new HatchPatternData();

					vHPData.baseP = new DPoint(0, 0, 0);
					vHPData.offset = new DPoint(300, 300, 0);
					vHPData.lineAngle = 40.0f;
					vHPData.isDash = false;
					vHPData.lines = null;
					vHPData.dashNum = 0;
					Hatch.HatchPatternData.Add(vHPData);
					Hatch.Loaded(this.cadImage.Converter);
					this.cadImage.CurrentLayout.Entities.Add(Hatch);
					this.cadImage.Converter.OnCreate(Hatch);					
				}
			}
			this.ResizeLayout();			
		}
Sergey.

Re: Add Hatch to Ellipse

Posted: 06 Dec 2008, 09:58
by Anderson
Dear Sergey,

Thanks for your reply. I can add hatch to the ellipse entity now.
Is there a common way to add hatch on diffrent kind entity ? (such as circle, ellipse, PolyLine ....)

I have another question :
I use the “MergeFilesDemoSite” program to merge 3 dxf files and save as a new .dxf file, but when I open the new .dxf file with “ViewerControlDemo “ program I got nothing (cann’t see anything), could you tell me the cause?

Thanks,
Anderson

Re: Add Hatch to Ellipse

Posted: 09 Dec 2008, 10:21
by support
Dear Anderson,
Is there a common way to add hatch on diffrent kind entity ? (such as circle, ellipse, PolyLine ....)
The common way is just as it was shown in the code example. Generally saying every new hatch requires personal solution.
I have another question :
I use the “MergeFilesDemoSite” program to merge 3 dxf files and save as a new .dxf file, but when I open the new .dxf file with “ViewerControlDemo “ program I got nothing (cann’t see anything), could you tell me the cause?
We have found this problem.

We will inform you when it is solved.

Sergey.

Re: Add Hatch to Ellipse

Posted: 24 Dec 2008, 16:24
by support
Hello!
I have another question :
I use the “MergeFilesDemoSite” program to merge 3 dxf files and save as a new .dxf file, but when I open the new .dxf file with “ViewerControlDemo “ program I got nothing (cann’t see anything), could you tell me the cause?
We have found this problem.

We will inform you when it is solved.
The problem has been solved.
Please contact us via e-mail to support@cadsofttools.com accordingly the question of getting updated beta version of the library.

Sergey.