This project has moved. For the latest updates, please go here.

Problem creating ellipse Hatch

Aug 25, 2015 at 9:10 PM
Edited Aug 25, 2015 at 9:44 PM
I'm trying to create ellipse hatch using the following code without success:
DxfDocument dxf = new DxfDocument();
Ellipse ellipse = new Ellipse(Vector3.Zero, 10, 10);
List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>
{
    new HatchBoundaryPath(new List<EntityObject>{ellipse})
};
Hatch hatch = new Hatch(HatchPattern.Solid, boundary, false);
dxf.AddEntity(hatch);
hatch.CreateBoundary(true);
dxf.Save("hatchEllipse.dxf");
but using the following code it is possible to create circle hatch:
DxfDocument dxf = new DxfDocument();
Circle circle = new Circle(Vector3.Zero, 5);
List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>
{
    new HatchBoundaryPath(new List<EntityObject>{circle})
};
Hatch hatch = new Hatch(HatchPattern.Solid, boundary, false);
dxf.AddEntity(hatch);
hatch.CreateBoundary(true);
dxf.Save("hatchCircle.dxf");
Aug 25, 2015 at 9:41 PM
When I set ellipse.EndAngle = 360.0 then the resulting code 51 is set in output file to 0 instead of to 360.
Aug 25, 2015 at 10:01 PM
In the MathHelper method:
        public static double NormalizeAngle(double angle)
        {
            double c = angle%360;
            if (c < 0)
                return 360.0 + c;
            return c;
        }
if EndAngle is to be set to 360 the NormalizeAngle returns 0 and in the result the SOLID code 51 is set to 0 and hatch is not displayed. The NormalizeAngle works correctly for Ellipse entity.
Coordinator
Aug 31, 2015 at 6:19 PM
I am normalizing all angle values in the range [0,360[, mathematically speaking 0 is the same as 360. In the case of an ellipse there is only one entity to represent an ellipse and an ellipse arc, unlike the circle that has one for each. So for the Ellipse entity as long as the start and end angle are equal it is considered a full ellipse, just check its corresponding property.

For the hatch to work properly it requires that in those cases the start and end angles to be 0 and 360 degrees respectively, the ellipse entity is written in the dxf in a totally different way. I will fix it in the next update.

Daniel