Beispiel #1
0
        public Oid CreateEntity(Database database)
        {
            var exterior = this.exterior;
            var ringType = exterior.Item;

            switch (ringType)
            {
            case LinearRingType lrt:
                DirectPositionListType dplt;
                if ((dplt = lrt.Items[0] as DirectPositionListType) != null)
                {
                    var points = dplt.GetPoints();

                    Point2dCollection points2d = new Point2dCollection();
                    DoubleCollection  dc       = new DoubleCollection();
                    //-1 beacuse the last point is a repetition of first
                    for (int i = 0; i < points.Length; i++)
                    {
                        points2d.Add(points[i].To2D());
                        dc.Add(0.0);
                    }

                    //Polyline pline = new Polyline(points.Length);
                    ////-1 beacuse the last point is a repetition of first
                    //for (int i = 0; i < points.Length - 1; i++)
                    //    pline.AddVertexAt(pline.NumberOfVertices, points[i].To2D(), 0, 0, 0);
                    //pline.Closed = true;
                    //Oid plineId = pline.AddEntityToDbModelSpace(database);

                    Hatch hatch = new Hatch();
                    hatch.Normal       = new Vector3d(0.0, 0.0, 1.0);
                    hatch.Elevation    = 0.0;
                    hatch.PatternScale = 1.0;
                    hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
                    Oid hatchId = hatch.AddEntityToDbModelSpace(database);

                    hatch.AppendLoop(HatchLoopTypes.Default, points2d, dc);
                    hatch.EvaluateHatch(true);

                    return(hatchId);
                }
                else
                {
                    throw new System.Exception(
                              $"Unexpected type in PolygonType.exterior.Item.Items[0]: {lrt.Items[0].GetType().Name}");
                }

            case RingType rt:
                throw new System.NotImplementedException();

            default:
                throw new System.Exception($"Unexpected type in PolygonType.exterior.Item: {ringType.GetType().Name}");
            }
        }