Ejemplo n.º 1
0
        private AcDb.ObjectId AddBorders()
        {
            AcDb.Polyline2d borderParcel = ServiceSimpleElements.CreatePolyline2d(this.Parcel.Points, true);
            borderParcel.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillParcel.Layer);
            AcDb.ObjectId idBorderParcel = ServiceCAD.InsertObject(borderParcel);

            AcDb.ResultBuffer xData = new AcDb.ResultBuffer();
            int dxfCode;

            AcDb.TypedValue typedValue;

            dxfCode    = (int)AcDb.DxfCode.ExtendedDataRegAppName;
            typedValue = new AcDb.TypedValue(dxfCode, "Земельна ділянка");
            xData.Add(typedValue);

            foreach (LandInfo infoValue in this.Parcel.Info)
            {
                dxfCode    = (int)AcDb.DxfCode.ExtendedDataAsciiString;
                typedValue = new AcDb.TypedValue(dxfCode, "<" + infoValue.Key + "> " + infoValue.Value);
                xData.Add(typedValue);
            }

            ServiceCAD.SetXData(idBorderParcel, xData);

            return(idBorderParcel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Створює елементи вектору з данними виносу.
        /// </summary>
        private void CreateDrawingStakeOut()
        {
            if (this.PointStation == null)
            {
                return;
            }

            AcGe.Point3d pntStart = new AcGe.Point3d(this.PointStation.E, this.PointStation.N, this.PointStation.H);
            AcGe.Point3d pntEnd   = new AcGe.Point3d(this.Coordinates.X, this.Coordinates.Y, 0);

            AcDb.Line line = new AcDb.Line(pntStart, pntEnd);
            line.Visible = this.Visible;

            AcGe.Point3d pntMiddle = new AcGe.LineSegment3d(pntStart, pntEnd).MidPoint;

            double angleTXT = line.Angle;

            if (angleTXT > Math.PI / 2 && angleTXT < Math.PI * 3 / 2)
            {
                angleTXT += Math.PI;
            }

            AcDb.MText text = new AcDb.MText();
            text.Contents = this.DistanceToString(AcRx.DistanceUnitFormat.Decimal) + "\r\n"
                            + "л.к. " + ServiceTable.FormatAngleValue(this.LeftlAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds));
            text.Rotation   = angleTXT;
            text.Location   = pntMiddle;
            text.Attachment = AcDb.AttachmentPoint.MiddleCenter;
            text.Width      = 25;
            text.TextHeight = 1.8 * this.ScaleDrawing;


            this.lineID = ServiceCAD.InsertObject(line);
            this.txtID  = ServiceCAD.InsertObject(text);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Видаляє елементи вектору з данними виносу.
        /// </summary>
        private void DeleteDrawingStakeOut()
        {
            ServiceCAD.DeleteObject(this.lineID);
            ServiceCAD.DeleteObject(this.txtID);

            this.txtID  = AcDb.ObjectId.Null;
            this.lineID = AcDb.ObjectId.Null;
        }
Ejemplo n.º 4
0
 public LocalPath(string pathName) : base()
 {
     try
     {
         this.RootDirectory = ServiceCAD.GetSystemVariableSrchPathByName(pathName);
     }
     finally
     //catch (Exception exc)
     {
     }
 }
Ejemplo n.º 5
0
        private void AddLengthLine()
        {
            //AcDb.DBText oText;
            AcDb.MText oMText;

            AcDb.Line     lineCur = null;
            AcDb.ObjectId idLineCur;

            AcGe.Point2d startPoint = this.Parcel.Points.ToArray()[this.Parcel.Points.Count - 1];
            AcGe.Point3d midPoint;

            foreach (AcGe.Point2d endPoint in this.Parcel.Points)
            {
                midPoint = new AcGe.Point3d((endPoint.X + startPoint.X) / 2, (endPoint.Y + startPoint.Y) / 2, 0);



                lineCur = new AcDb.Line(new AcGe.Point3d(startPoint.X, startPoint.Y, 0),
                                        new AcGe.Point3d(endPoint.X, endPoint.Y, 0));

                lineCur.ColorIndex = 222;
                lineCur.LineWeight = AcDb.LineWeight.LineWeight030;
                idLineCur          = ServiceCAD.InsertObject(lineCur);

                ServiceCAD.ZoomCenter(midPoint, 1);

                /*
                 * oText = new AcDb.DBText();
                 * oText.Height = 2 * this.SettingsForm.ScaleDrawing;
                 * oText.TextString = startPoint.GetDistanceTo(endPoint).ToString("0.00").Replace(",",".");
                 * //oText.Layer = settingsDrawing.Plan.LengthLine.Layer;
                 *
                 * ServiceCAD.ManualInsertText(oText);
                 */

                oMText            = new AcDb.MText();
                oMText.TextHeight = 2 * this.SettingsForm.ScaleDrawing;
                oMText.Attachment = AcDb.AttachmentPoint.MiddleCenter;
                //oMText.Layer = settingsDrawing.Plan.LengthLine.Layer;

                oMText.Contents = startPoint.GetDistanceTo(endPoint).ToString("0.00").Replace(",", ".");

                ServiceCAD.ZoomCenter(midPoint, 1);
                ServiceSimpleElements.ManualInsertMText(oMText);
                ServiceCAD.DeleteObject(idLineCur);

                startPoint = endPoint;
            }
        }
Ejemplo n.º 6
0
        static List <AcDb.ObjectId> InsertAllParcel(BL blockLand, AcGe.Vector2d offset)
        {
            AcDb.Polyline2d        curPolyline;
            AcGe.Point2dCollection points;
            List <AcDb.ObjectId>   listObjectId = new List <AcDb.ObjectId>();

            foreach (SR sr in blockLand.SR)
            {
                points      = ServiceSimpleElements.Offset(ServiceIn4.GetPoints2dFromIn4Polygon(sr), offset);
                curPolyline = ServiceSimpleElements.CreatePolyline2d(points, true);
                listObjectId.Add(ServiceCAD.InsertObject(curPolyline));
            }

            return(listObjectId);
        }
Ejemplo n.º 7
0
        private void BtnSelectFile_Click(object sender, EventArgs e)
        {
            Stream         myStream      = null;
            OpenFileDialog openDialogIn4 = new OpenFileDialog
            {
                InitialDirectory = new LocalPath("LoSa_Land").FindFullPathFromXml("PathExpotrSDR"),
                Filter           = "Файл обміну (*.in4)|*.in4|Усі файли (*.*)|*.*"
            };

            if (openDialogIn4.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openDialogIn4.OpenFile()) != null)
                    {
                        PurgeFromElementsBlockLand();
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Помилка: " + ex.Message);
                }

                this.comboBoxNumberParcel.Items.Clear();

                this.currentBlockLand = ServiceIn4.GetDataFromFileIN4(openDialogIn4.FileName);
                //int indexSR = 0;
                foreach (SR currentSR in this.currentBlockLand.SR)
                {
                    if (currentSR.SC != null)
                    {
                        this.comboBoxNumberParcel.Items.Add(currentSR.SC);
                    }
                    else
                    {
                        MessageBox.Show(" !!!!!! currentSR.SC == null"); return;
                    }
                    //indexSR++;
                }

                this.comboBoxNumberParcel.SelectedIndex = 0;
                allIdBlockLandParcel = InsertAllParcel(currentBlockLand, this.offsetBlockLandView);
                ServiceCAD.ZoomExtents();
            }
        }
Ejemplo n.º 8
0
        private void AddNumdersPoints()
        {
            int iCurNumberPoint = 0;

            //AcDb.DBText oText;
            AcDb.MText oMText;

            AcDb.Circle   circleCurPoint = null;
            AcDb.ObjectId idCircleCurPoint;

            foreach (AcGe.Point2d point in this.Parcel.Points)
            {
                iCurNumberPoint += 1;

                circleCurPoint = new AcDb.Circle(
                    new AcGe.Point3d(point.X, point.Y, 0),
                    new AcGe.Vector3d(0, 0, 1),
                    1.75 * this.SettingsForm.ScaleDrawing);

                circleCurPoint.ColorIndex = 222;
                circleCurPoint.LineWeight = AcDb.LineWeight.LineWeight030;
                idCircleCurPoint          = ServiceCAD.InsertObject(circleCurPoint);

                /*
                 * oText = new AcDb.DBText();
                 * oText.TextString = Convert.ToString(iCurNumberPoint);
                 * oText.Height = settingsDrawing.Plan.NumberPoint.TextHeight * this.SettingsForm.ScaleDrawing;
                 * //oText.Layer = settingsDrawing.Plan.NumberPoint.Layer;
                 */

                oMText            = new AcDb.MText();
                oMText.TextHeight = 2 * this.SettingsForm.ScaleDrawing;
                oMText.Attachment = AcDb.AttachmentPoint.MiddleCenter;
                //oMText.Layer = settingsDrawing.Plan.LengthLine.Layer;

                oMText.Contents = Convert.ToString(iCurNumberPoint);

                ServiceCAD.ZoomCenter(new AcGe.Point3d(point.X, point.Y, 0), 1);
                ServiceSimpleElements.ManualInsertMText(oMText);
                ServiceCAD.DeleteObject(idCircleCurPoint);
            }
        }
Ejemplo n.º 9
0
        private void AddPoints(AcDb.ObjectId idBorderParcel)
        {
            AcDb.ResultBuffer xData = new AcDb.ResultBuffer();
            int dxfCode;

            AcDb.TypedValue typedValue;

            dxfCode    = (int)AcDb.DxfCode.ExtendedDataRegAppName;
            typedValue = new AcDb.TypedValue(dxfCode, "Точки межі");
            xData.Add(typedValue);

            int iCurNumberPoint = 0;

            Dictionary <string, string> tags = new Dictionary <string, string>();

            foreach (AcGe.Point2d point in this.Parcel.Points)
            {
                iCurNumberPoint += 1;
                tags.Clear();
                tags.Add("NUMBER", "");
                AcDb.ObjectId idPoint = ServiceBlockElements.InsertBlock
                                        (
                    settingsDrawing.Plan.Point.NameBlock,
                    new AcGe.Point3d(point.X, point.Y, 0.0),
                    this.SettingsForm.ScaleDrawing,
                    0,
                    ServiceCAD.CreateLayer(settingsDrawing.Plan.Point.Layer),
                    tags
                                        );

                //dxfCode = (int)DxfCode.ExtendedDataHandle;
                dxfCode    = (int)AcDb.DxfCode.ExtendedDataAsciiString;
                typedValue = new AcDb.TypedValue(dxfCode, point.ToString());
                xData.Add(typedValue);
            }
            if (!idBorderParcel.Equals(AcDb.ObjectId.Null))
            {
                ServiceCAD.SetXData(idBorderParcel, xData);
            }
        }
Ejemplo n.º 10
0
        private void PurgeFromElementsBlockLand()
        {
            if (this.currentBlockLand != null)
            {
                this.currentBlockLand = null;
            }

            if (!this.idCurrentHatchParcel.IsNull)
            {
                ServiceCAD.DeleteObject(this.idCurrentHatchParcel);
                this.idCurrentHatchParcel = new AcDb.ObjectId();
            }

marker_reSart_allIdBlockLandParcel:

            foreach (AcDb.ObjectId objectId in allIdBlockLandParcel)
            {
                ServiceCAD.DeleteObject(objectId);
                allIdBlockLandParcel.Remove(objectId);
                goto marker_reSart_allIdBlockLandParcel;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public void Initialize()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

ReStartImportBlock:

            try
            {
                ServiceCAD.ImportBlockFromPath(LocalPath.RootDirectory + "\\blocks\\");
            }
            catch (DirectoryNotFoundException dirExc)
            {
                string msgDirExc = "<!> \n<!>" + dirExc.Message + "\n<!>";

                CurrentCAD.Editor.WriteMessage(msgDirExc);

                Directory.CreateDirectory(LocalPath.RootDirectory + "\\blocks\\");
                goto ReStartImportBlock;
            }

            string msgPorgam = "\n--------------------------------------";

            msgPorgam += "\n > Name: " + assembly.GetName().Name;
            msgPorgam += "\n > Версия: " + assembly.GetName().Version;
            msgPorgam += "\n---------------------------------------";
            msgPorgam += "\n > email: [email protected] ";
            msgPorgam += "\n--------------------------------------";
            msgPorgam += "\n *Land_CreatingPlanLand - ";
            msgPorgam += "\n Land_IntersectionGridLines - ";
            msgPorgam += "\n Land_InsertBlocksAlongLine - ";
            msgPorgam += "\n Land_OrthogonalPolylines - ";
            msgPorgam += "\n Land_BuildingRectangle - ";
            msgPorgam += "\n Land_AddRaster2000 - ";
            msgPorgam += "\n Land_DelRaster2000 - ";
            msgPorgam += "\n--------------------------------------";


            CurrentCAD.Editor.WriteMessage(msgPorgam);
        }
Ejemplo n.º 12
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");
            }
        }
Ejemplo n.º 13
0
        private void ComboBoxNumberParcel_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.Text          = this.comboBoxNumberParcel.SelectedItem.ToString();
            this.currentParcel = ServiceIn4.GetParcelForCadarstralNumber
                                     (this.currentBlockLand, this.comboBoxNumberParcel.SelectedItem.ToString());
            if (!this.idCurrentHatchParcel.IsNull)
            {
                ServiceCAD.DeleteObject(this.idCurrentHatchParcel);
                ServiceCAD.DeleteObjects(this.idNeighborsCurrenParcel);
            }

            serviceParcel = new ServiceParcel(this.currentParcel, this.formSettings);

            AcGe.Point2dCollection pointsCurrentHatchParcel =
                ServiceSimpleElements.Offset(this.currentParcel.Points, this.offsetBlockLandView);
            AcDb.ObjectId idPolyline2d =
                ServiceCAD.InsertObject(ServiceSimpleElements.CreatePolyline2d(pointsCurrentHatchParcel, true));
            AcDb.Hatch curHatch =
                ServiceSimpleElements.CreateHatch(new AcDb.ObjectIdCollection(new AcDb.ObjectId[] { idPolyline2d }));
            this.idCurrentHatchParcel =
                ServiceCAD.InsertObject(curHatch);
            ServiceCAD.DeleteObject(idPolyline2d);


            // =======================================================

            if (this.currentParcel.StakeOutParcelPoints != null)
            {
                this.currentParcel.StakeOutParcelPoints.Clear();
            }

            StakeOutParcelPoint stakeOutParcelPoint;

            this.dataGridView_StakeOut.ClearSelection();
            this.dataGridView_StakeOut.Rows.Clear();

            int indexPoint = 0;

            object[] row = new object[2];

            foreach (AcGe.Point2d point in this.currentParcel.Points)
            {
                indexPoint++;

                stakeOutParcelPoint = new StakeOutParcelPoint
                {
                    ScaleDrawing = this.drawingSettings.Scale.Value,
                    Name         = indexPoint.ToString(),
                    Coordinates  = point
                };

                this.currentParcel.StakeOutParcelPoints.Add(stakeOutParcelPoint);
                row[0] = false;
                row[1] = indexPoint.ToString();

                this.dataGridView_StakeOut.Rows.Add(row);
            }

            SetColPointStationAndOrientationItems();
            AutoSearchingStationAndOrientationForAllPoints();

            this.dataGridView_StakeOut.Update();

            ReLoad_treeViewParcel();
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        public static void AttachRasterImage(LandRasterImage landRastr)
        {
            AcEd.Editor ed = AcApp.DocumentManager.MdiActiveDocument.Editor;

            //bool bRasterDefCreated = false;

            AcDb.Database curDb = AcApp.DocumentManager.MdiActiveDocument.Database;

            using (AcDb.Transaction tr = curDb.TransactionManager.StartTransaction())
            {
                AcDb.RasterImageDef rasterDef;
                AcDb.ObjectId       imgDefId;
                AcDb.ObjectId       imgDctID = AcDb.RasterImageDef.GetImageDictionary(curDb);
                if (imgDctID.IsNull)
                {
                    imgDctID = AcDb.RasterImageDef.CreateImageDictionary(curDb);
                }

                AcDb.DBDictionary imgDict = (AcDb.DBDictionary)tr.GetObject(imgDctID, AcDb.OpenMode.ForRead);

                if (imgDict.Contains(landRastr.ImageName))
                {
                    imgDefId  = imgDict.GetAt(landRastr.ImageName);
                    rasterDef = (AcDb.RasterImageDef)tr.GetObject(imgDefId, AcDb.OpenMode.ForWrite);
                    if (rasterDef.IsLoaded)
                    {
                        //return;
                    }
                }
                else
                {
                    AcPApp.AcadApplication app    = AcApp.AcadApplication as AcPApp.AcadApplication;
                    AcPApp.AcadDocument    doc    = app.ActiveDocument;
                    AcPDb.AcadModelSpace   mSpace = doc.ModelSpace;
                    AcPDb.AcadRasterImage  ri     = mSpace.AddRaster(landRastr.FileName, landRastr.InsertPoint.ToArray(), 1000, 0);
                    ri.Name         = landRastr.ImageName;
                    ri.Transparency = true;
                    ServiceCAD.CreateLayer(landRastr.Layer);
                    ri.Layer       = landRastr.Layer;
                    ri.ImageHeight = 1000;
                    ri.ImageWidth  = 1000;

                    tr.Commit();
                    return;
                }

                AcDb.BlockTable blkTbl =
                    (AcDb.BlockTable)tr.GetObject(curDb.BlockTableId, AcDb.OpenMode.ForRead);

                AcDb.BlockTableRecord acBlkTblRec =
                    (AcDb.BlockTableRecord)tr.GetObject(blkTbl[AcDb.BlockTableRecord.ModelSpace], AcDb.OpenMode.ForWrite);

                using (AcDb.RasterImage rasterImage = new AcDb.RasterImage())
                {
                    rasterImage.ImageDefId = imgDefId;

                    AcGe.Vector3d width;
                    AcGe.Vector3d height;

                    AcGe.Matrix3d ucs  = ed.CurrentUserCoordinateSystem;
                    double        size = 1000;

                    width  = new AcGe.Vector3d(size, 0, 0);
                    height = new AcGe.Vector3d(0, size, 0);


                    AcGe.Point3d            insPt            = landRastr.InsertPoint;
                    AcGe.CoordinateSystem3d coordinateSystem = new AcGe.CoordinateSystem3d(insPt.TransformBy(ucs), width.TransformBy(ucs), height.TransformBy(ucs));
                    rasterImage.Orientation = coordinateSystem;
                    rasterImage.Rotation    = 0;
                    rasterImage.ShowImage   = true;

                    acBlkTblRec.AppendEntity(rasterImage);
                    tr.AddNewlyCreatedDBObject(rasterImage, true);

                    rasterImage.AssociateRasterDef(rasterDef);
                }
                tr.Commit();
            }
        }