Add Hatch to Ellipse

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Anderson
Posts: 13
Joined: 04 Dec 2008, 12:55

Add Hatch to Ellipse

Post by Anderson » 05 Dec 2008, 07:20

Hello,

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

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Add Hatch to Ellipse

Post by support » 05 Dec 2008, 12:40

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Anderson
Posts: 13
Joined: 04 Dec 2008, 12:55

Re: Add Hatch to Ellipse

Post by Anderson » 06 Dec 2008, 09:58

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

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Add Hatch to Ellipse

Post by support » 09 Dec 2008, 10:21

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Add Hatch to Ellipse

Post by support » 24 Dec 2008, 16:24

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply