cart: empty [ Login ]

BoundrayPath from array of Points

1 
vjedlicka
11/9/2008 10:52 AM

Hello, I have an array of Points and would like to export a filled polygon. I probably need a hatch with DxfHatch.BoundaryPath.LineEdge objects. Do I need to add them to the BoundaryPath in a loop or is there a way to just pass the array? Thanks Vaclav

Wout
11/9/2008 11:45 AM

Hi Vaclav, It's probably easier to use the BoundaryPath.PolylineData. Set the polyline data to a new DxfHatch.BoundaryPath.Polyline instance and add your points to it. Wout

vjedlicka
11/9/2008 12:49 PM

Hi Wout Thank you for your quick response! It works well. Adding code for the case anyone needs it

C# Code:
    private static void ExportPolygonSolid(DxfEntityCollection a_coll, Point2D[] a_points, ObjProps objProps)     {       DxfHatch l_hatch = new DxfHatch();       l_hatch.Color = objProps.m_logbrush.m_color;       l_hatch.ColorSource = AttributeSource.This;       DxfHatch.BoundaryPath boundaryPath1 = new DxfHatch.BoundaryPath();       boundaryPath1.Type = BoundaryPathType.Polyline;       boundaryPath1.PolylineData = new DxfHatch.BoundaryPath.Polyline(a_points);       l_hatch.BoundaryPaths.Add(boundaryPath1);       a_coll.Add(l_hatch);     }

vjedlicka
11/9/2008 1:34 PM

I am trying to add hatching to the function. When I run it I get the response I attached (screenshot). Vaclav

C# Code:
    private static void ExportPolygonSolid(DxfEntityCollection a_coll, Point2D[] a_points, ObjProps a_objProps)     {       DxfHatch l_hatch = new DxfHatch();       //l_hatch.Color = a_objProps.m_logbrush.m_color;       l_hatch.ColorSource = AttributeSource.This;       DxfHatch.BoundaryPath boundaryPath1 = new DxfHatch.BoundaryPath();       boundaryPath1.Type = BoundaryPathType.Polyline;       boundaryPath1.PolylineData = new DxfHatch.BoundaryPath.Polyline(a_points);       l_hatch.BoundaryPaths.Add(boundaryPath1);              if (a_objProps.m_hatchtype != HatchType.NONE)       {         DxfPattern pattern = GetHatchPattern(a_objProps);         if (pattern != null)         {           l_hatch.Pattern = pattern;         }       }       a_coll.Add(l_hatch);     }

error.JPG
Wout
11/10/2008 1:00 PM

Hi Vaclav, Can you create a small program to reproduce the problem for me, that makes it easier for me to see what's wrong. Thanks! Wout

vjedlicka
11/10/2008 7:55 PM

Hi Wout, I noticed the word Error is written out for each line that was missing in the hatching. If I change the shape I always get different number of Errors. I can shape the polygon so that I do not get any error. I think the last edge is missing from the polyline (when used the code I sent). I fixed the issue by using this code:

C# Code:
      Point2D l_pointOld = new Point2D(a_points[0].X, a_points[0].Y);       for (int li_i = 1; li_i < a_points.Length; li_i++)       {         Point2D l_pointNew = new Point2D(a_points[li_i].X, a_points[li_i].Y);         boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(l_pointOld, l_pointNew));         l_pointOld = l_pointNew;       }
Problem solved, so I do not need response for this. Thanks Vaclav

1