示例#1
0
        public static AcDb.Hatch CreateHatch(AcDb.ObjectIdCollection objectIds, bool removeBoundaries)
        {
            AcDb.Hatch    oHatch = new AcDb.Hatch();
            AcGe.Vector3d normal = new AcGe.Vector3d(0.0, 0.0, 1.0);
            oHatch.Normal       = normal;
            oHatch.Elevation    = 0;
            oHatch.PatternScale = 1;
            oHatch.SetHatchPattern(AcDb.HatchPatternType.UserDefined, "ANSI31");
            oHatch.ColorIndex  = 1;
            oHatch.Associative = true;
            oHatch.AppendLoop((int)AcDb.HatchLoopTypes.Default, objectIds);
            oHatch.EvaluateHatch(true);

            if (removeBoundaries)
            {
                ServiceCAD.DeleteObjects(objectIds);
            }

            return(oHatch);
        }
示例#2
0
        private void AddFills()
        {
            Dictionary <string, HatchPolygon> listMissingHatch = new Dictionary <string, HatchPolygon>();

            //
            //  Parcel
            //

            if (SettingsForm.DisplayFillParcel)
            {
                AcDb.Polyline2d borderParcel      = ServiceSimpleElements.CreatePolyline2d(this.Parcel.Points, true);
                AcDb.ObjectId   idBorderParcel    = ServiceCAD.InsertObject(borderParcel);
                AcDb.Hatch      borderParcelHatch = ServiceSimpleElements.CreateHatch(idBorderParcel, true);

                HatchPolygon hatchParcel = HatchPolygon.GetHatchParcel();

                if (hatchParcel != null)
                {
                    borderParcelHatch.LayerId    = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillParcel.Layer);
                    borderParcelHatch.ColorIndex = hatchParcel.ColorIndex;
                    borderParcelHatch.SetHatchPattern(hatchParcel.Pattern.Type, hatchParcel.Pattern.Name);
                    borderParcelHatch.PatternAngle = hatchParcel.Pattern.Angle;
                    borderParcelHatch.PatternSpace = hatchParcel.Pattern.Space;

                    AcDb.ObjectId idborderParcelHatch = ServiceCAD.InsertObject(borderParcelHatch);
                }
                else
                {
                    try
                    {
                        listMissingHatch.Add("Parcel", new HatchPolygon("Parcel", "", 0, PatternHatch.DEFAULT));
                        CurrentCAD.Editor.WriteMessage("\n<!> Незнайдено штриховка Parcel;");
                    }
                    catch { }
                }
            }

            //
            //  Lands
            //

            AcDb.Polyline2d borderLand;
            AcDb.ObjectId   idLand;
            AcDb.Hatch      hatchLand;
            AcDb.ObjectId   idHatchLand;

            if (SettingsForm.DisplayFillLand)
            {
                foreach (LandPolygon poligon in this.Parcel.Lands)
                {
                    borderLand         = ServiceSimpleElements.CreatePolyline2d(poligon.Points, true);
                    borderLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLand.Layer);
                    idLand             = ServiceCAD.InsertObject(borderLand);
                    hatchLand          = ServiceSimpleElements.CreateHatch(idLand, false);

                    HatchPolygon hatch = HatchPolygon.GetHatchLand(poligon);

                    if (hatch != null)
                    {
                        hatchLand.LayerId    = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLand.Layer);
                        hatchLand.ColorIndex = hatch.ColorIndex;
                        hatchLand.SetHatchPattern(hatch.Pattern.Type, hatch.Pattern.Name);
                        hatchLand.PatternAngle = hatch.Pattern.Angle;
                        hatchLand.PatternSpace = hatch.Pattern.Space;

                        idHatchLand = ServiceCAD.InsertObject(hatchLand);
                    }
                    else
                    {
                        string type = "000.00";
                        try
                        {
                            type = poligon.FindInfo("CC").Value;
                        }
                        catch
                        {
                            string ci = "*";
                            string cn = "*";
                            try
                            {
                                LandInfo infoCI = poligon.FindInfo("CI");
                                ci = infoCI.Value;
                            }
                            catch { }

                            try
                            {
                                LandInfo infoCN = poligon.FindInfo("CN");
                                cn = infoCN.Value;
                            }
                            catch { }

                            CurrentCAD.Editor.WriteMessage
                                ("\n<!> Незнайдено поле CC угіддя CI = {0}, CN = {1};",
                                ci,
                                cn);
                        }

                        try
                        {
                            listMissingHatch.Add(type, new HatchPolygon(type, "", 0, PatternHatch.DEFAULT));
                            CurrentCAD.Editor.WriteMessage
                                ("\n<!> Незнайдено CC = {0};",
                                poligon.FindInfo("CC").Value
                                );
                        }
                        catch { }
                    }
                }
            }

            //
            //  Limiting
            //

            if (SettingsForm.DisplayFillLimiting)
            {
                foreach (LandPolygon poligon in this.Parcel.Limiting)
                {
                    borderLand         = ServiceSimpleElements.CreatePolyline2d(poligon.Points, true);
                    borderLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLimiting.Layer);
                    idLand             = ServiceCAD.InsertObject(borderLand);
                    hatchLand          = ServiceSimpleElements.CreateHatch(idLand, false);

                    HatchPolygon hatchLimiting = HatchPolygon.GetHatchLimiting(poligon);

                    if (hatchLimiting != null)
                    {
                        hatchLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLimiting.Layer);

                        hatchLand.ColorIndex = hatchLimiting.ColorIndex;
                        hatchLand.SetHatchPattern(hatchLimiting.Pattern.Type, hatchLimiting.Pattern.Name);
                        hatchLand.PatternAngle = hatchLimiting.Pattern.Angle;
                        hatchLand.PatternSpace = hatchLimiting.Pattern.Space;

                        idHatchLand = ServiceCAD.InsertObject(hatchLand);
                    }
                    else
                    {
                        string type = poligon.FindInfo("OK").Value;
                        string name = poligon.FindInfo("OX").Value;
                        try
                        {
                            listMissingHatch.Add((type + name), new HatchPolygon(type, name, 0, PatternHatch.DEFAULT));
                            CurrentCAD.Editor.WriteMessage
                                ("\n<!> Незнайдено OK = {0}, OX = {1};",
                                poligon.FindInfo("OK").Value,
                                poligon.FindInfo("OX").Value
                                );
                        }
                        catch { }
                    }
                }
            }

            if (listMissingHatch.Count > 0)
            {
                List <HatchPolygon> listForXml = new List <HatchPolygon>();
                foreach (KeyValuePair <string, HatchPolygon> hp in listMissingHatch)
                {
                    listForXml.Add(hp.Value);
                }
                listMissingHatch.Clear();
                CurrentCAD.Editor.WriteMessage("\n\n<!> Побудова плана ділянки\n<!> Не визначено штриховку: \n");
                CurrentCAD.Editor.WriteMessage(ServiceXml.GetStringXml <List <HatchPolygon> >(listForXml));
                CurrentCAD.Editor.WriteMessage("\n<!>\n");
            }
        }
示例#3
0
        /// <summary>
        /// Створює коллекцію текстових обектів значень данних таблиці обмежень земельної ділянки.
        /// </summary>
        /// <param name="parcel">Ділянка, що є вихідною для таблиці.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        ///  Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці обмежень земельної ділянки.
        /// </returns>

        internal static AcDb.DBObjectCollection GetDataTableLimiting(LandParcel parcel, SettingTable settingTable)
        {
            AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection();

            AcDb.MText   valueMText;
            AcGe.Point3d insertPoint;
            AcDb.Line    lineRows;

            LandPolygon polygonLimiting;

            double steepRow    = settingTable.TextHeight * 6;
            double heightTable = settingTable.GetHeightCapTable() * -1;

            List <HatchPolygon> listMissingHatch = new List <HatchPolygon>();

            for (int index = 0; index < parcel.Limiting.Count; index++)
            {
                polygonLimiting = parcel.Limiting.ToArray()[index];

                double colWidth = 0;

                if (index > 0)
                {
                    lineRows = new AcDb.Line(
                        new AcGe.Point3d(0, heightTable, 0),
                        new AcGe.Point3d(settingTable.GetWidthTable(), heightTable, 0));

                    objects.Add(lineRows);
                }

                heightTable -= steepRow;



                foreach (ColumnTable col in settingTable.Columns)
                {
                    colWidth += col.Width;

                    insertPoint = new AcGe.Point3d();
                    insertPoint = new AcGe.Point3d(colWidth - col.Width / 2, (heightTable + steepRow / 2), 0);

                    valueMText                   = new AcDb.MText();
                    valueMText.Width             = col.Width * 0.9;
                    valueMText.TextHeight        = settingTable.TextHeight;
                    valueMText.LineSpaceDistance = settingTable.TextHeight * 1.5;
                    valueMText.Attachment        = AcDb.AttachmentPoint.MiddleCenter;
                    valueMText.Location          = insertPoint;

                    if (col.Format.IndexOf("LegendLimiting") > -1)
                    {
                        AcGe.Point2dCollection pointsHatch = new AcGe.Point2dCollection(new AcGe.Point2d[]
                        {
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + steepRow - 2),
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + 2),
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + 2),
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + steepRow - 2)
                        });

                        AcDb.Polyline2d polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true);
                        AcDb.Hatch      hatch            =
                            ServiceSimpleElements.CreateHatch(ServiceCAD.InsertObject(polylineLimiting), true);

                        HatchPolygon hatchLimiting = HatchPolygon.GetHatchLimiting(polygonLimiting);

                        if (hatchLimiting != null)
                        {
                            hatch.ColorIndex = hatchLimiting.ColorIndex;
                            hatch.SetHatchPattern(AcDb.HatchPatternType.UserDefined, hatchLimiting.Pattern.Name);
                            hatch.PatternAngle = hatchLimiting.Pattern.Angle;
                            hatch.PatternSpace = hatchLimiting.Pattern.Space;
                        }
                        else
                        {
                            string type = polygonLimiting.FindInfo("OK").Value;
                            string name = polygonLimiting.FindInfo("OX").Value;
                            listMissingHatch.Add(new HatchPolygon(type, name, 0, PatternHatch.DEFAULT));
                        }

                        objects.Add(hatch);
                        polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true);
                        objects.Add(polylineLimiting);
                    }
                    else if (col.Format.IndexOf("CodeLimiting") > -1)
                    {
                        valueMText.Contents = polygonLimiting.FindInfo("OK").Value;
                        objects.Add(valueMText);
                    }
                    else if (col.Format.IndexOf("NameLimiting") > -1)
                    {
                        valueMText.Contents = polygonLimiting.FindInfo("OX").Value;
                        objects.Add(valueMText);
                    }
                    else if (col.Format.IndexOf("LegalActsLimiting") > -1)
                    {
                        valueMText.Contents = polygonLimiting.FindInfo("OD").Value;
                        objects.Add(valueMText);
                    }
                    else if (col.Format.IndexOf("AreaLimiting") > -1)
                    {
                        double area = Convert.ToDouble(polygonLimiting.FindInfo("AO").Value.Replace(".", ","));
                        valueMText.Contents = (area / 10000).ToString("0.0000").Replace(",", ".");;
                        objects.Add(valueMText);
                    }
                }
            }

            if (listMissingHatch.Count > 0)
            {
                CurrentCAD.Editor.WriteMessage("\n\nПобудова таблиці омеженнь\n Не визначено штриховку: \n");
                CurrentCAD.Editor.WriteMessage(ServiceXml.GetStringXml <List <HatchPolygon> >(listMissingHatch));
            }

            return(objects);
        }