Beispiel #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);
        }
Beispiel #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");
            }
        }
Beispiel #3
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();
        }
Beispiel #4
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);
        }
Beispiel #5
0
        private string jsonGetObjectData(ObjectId id_platf)
        {
            string result = "";

            try
            {//Всякое может случиться
                //Открываем переданный в функцию объект на чтение, преобразуем его к Entity
                Entity ent = (Entity)id_platf.GetObject(OpenMode.ForRead);

                //Далее последовательно проверяем класс объекта на соответствие классам основных примитивов

                if (id_platf.ObjectClass.Name == "AcDbLine")
                {                                                       //Если объект - отрезок (line)
                    crawlAcDbLine kline = new crawlAcDbLine((Line)ent); //Преобразуем к типу линия
                    result = jsonHelper.To <crawlAcDbLine>(kline);
                }
                else if (id_platf.ObjectClass.Name == "AcDbPolyline")
                {//Если объект - полилиния
                    Polyline          kpLine = (Polyline)ent;
                    crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine);
                    result = jsonHelper.To <crawlAcDbPolyline>(jpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDb2dPolyline")
                {//2D полилиния - такие тоже попадаются
                    Polyline2d        kpLine = (Polyline2d)ent;
                    crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine);
                    result = jsonHelper.To <crawlAcDbPolyline>(jpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDb3dPolyline")
                {//2D полилиния - такие тоже попадаются
                    Polyline3d kpLine = (Polyline3d)ent;

                    crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine);
                    result = jsonHelper.To <crawlAcDbPolyline>(jpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDbText")
                { //Текст
                    DBText        dbtxt = (DBText)ent;
                    crawlAcDbText jtext = new crawlAcDbText(dbtxt);
                    result = jsonHelper.To <crawlAcDbText>(jtext);
                }
                else if (id_platf.ObjectClass.Name == "AcDbMText")
                {//Мтекст
                    MText          mtxt  = (MText)ent;
                    crawlAcDbMText jtext = new crawlAcDbMText(mtxt);
                    result = jsonHelper.To <crawlAcDbMText>(jtext);
                }
                else if (id_platf.ObjectClass.Name == "AcDbArc")
                {//Дуга
                    Arc          arc  = (Arc)ent;
                    crawlAcDbArc cArc = new crawlAcDbArc(arc);
                    result = jsonHelper.To <crawlAcDbArc>(cArc);
                }
                else if (id_platf.ObjectClass.Name == "AcDbCircle")
                {//Окружность
                    Circle          circle  = (Circle)ent;
                    crawlAcDbCircle cCircle = new crawlAcDbCircle(circle);
                    result = jsonHelper.To <crawlAcDbCircle>(cCircle);
                }
                else if (id_platf.ObjectClass.Name == "AcDbEllipse")
                {  //Эллипс
                    Ellipse          el   = (Ellipse)ent;
                    crawlAcDbEllipse cEll = new crawlAcDbEllipse(el);
                    result = jsonHelper.To <crawlAcDbEllipse>(cEll);
                }
                else if (id_platf.ObjectClass.Name == "AcDbAlignedDimension")
                {//Размер повернутый
                    AlignedDimension dim = (AlignedDimension)ent;

                    crawlAcDbAlignedDimension rDim = new crawlAcDbAlignedDimension(dim);
                    result = jsonHelper.To <crawlAcDbAlignedDimension>(rDim);
                }

                else if (id_platf.ObjectClass.Name == "AcDbRotatedDimension")
                {//Размер повернутый
                    RotatedDimension dim = (RotatedDimension)ent;

                    crawlAcDbRotatedDimension rDim = new crawlAcDbRotatedDimension(dim);
                    result = jsonHelper.To <crawlAcDbRotatedDimension>(rDim);
                }

                else if (id_platf.ObjectClass.Name == "AcDbPoint3AngularDimension")
                {//Угловой размер по 3 точкам
                    Point3AngularDimension dim = (Point3AngularDimension)ent;

                    crawlAcDbPoint3AngularDimension rDim = new crawlAcDbPoint3AngularDimension(dim);
                    result = jsonHelper.To <crawlAcDbPoint3AngularDimension>(rDim);
                }

                else if (id_platf.ObjectClass.Name == "AcDbLineAngularDimension2")
                {//Еще угловой размер по точкам
                    LineAngularDimension2 dim = (LineAngularDimension2)ent;

                    crawlAcDbLineAngularDimension2 rDim = new crawlAcDbLineAngularDimension2(dim);
                    result = jsonHelper.To <crawlAcDbLineAngularDimension2>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbDiametricDimension")
                {  //Размер диаметра окружности
                    DiametricDimension          dim  = (DiametricDimension)ent;
                    crawlAcDbDiametricDimension rDim = new crawlAcDbDiametricDimension(dim);
                    result = jsonHelper.To <crawlAcDbDiametricDimension>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbArcDimension")
                {  //Дуговой размер
                    ArcDimension          dim  = (ArcDimension)ent;
                    crawlAcDbArcDimension rDim = new crawlAcDbArcDimension(dim);
                    result = jsonHelper.To <crawlAcDbArcDimension>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbRadialDimension")
                {  //Радиальный размер
                    RadialDimension          dim  = (RadialDimension)ent;
                    crawlAcDbRadialDimension rDim = new crawlAcDbRadialDimension(dim);
                    result = jsonHelper.To <crawlAcDbRadialDimension>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbAttributeDefinition")
                {  //Атрибут блока
                    AttributeDefinition ad = (AttributeDefinition)ent;

                    crawlAcDbAttributeDefinition atd = new crawlAcDbAttributeDefinition(ad);
                    result = jsonHelper.To <crawlAcDbAttributeDefinition>(atd);
                }
                else if (id_platf.ObjectClass.Name == "AcDbHatch")
                {//Штриховка
                    Teigha.DatabaseServices.Hatch htch = ent as Teigha.DatabaseServices.Hatch;

                    crawlAcDbHatch cHtch = new crawlAcDbHatch(htch);
                    result = jsonHelper.To <crawlAcDbHatch>(cHtch);
                }
                else if (id_platf.ObjectClass.Name == "AcDbSpline")
                {//Сплайн
                    Spline spl = ent as Spline;

                    crawlAcDbSpline cScpline = new crawlAcDbSpline(spl);
                    result = jsonHelper.To <crawlAcDbSpline>(cScpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDbPoint")
                {//Точка
                    DBPoint        Pnt = ent as DBPoint;
                    crawlAcDbPoint pt  = new crawlAcDbPoint(Pnt);
                    result = jsonHelper.To <crawlAcDbPoint>(pt);
                }

                else if (id_platf.ObjectClass.Name == "AcDbBlockReference")
                {//Блок
                    BlockReference          blk  = ent as BlockReference;
                    crawlAcDbBlockReference cBlk = new crawlAcDbBlockReference(blk);

                    result = jsonHelper.To <crawlAcDbBlockReference>(cBlk);

                    //newDocument(id_platf, result);
                }
                else if (id_platf.ObjectClass.Name == "AcDbProxyEntity")
                {//Прокси
                    ProxyEntity pxy = ent as ProxyEntity;


                    crawlAcDbProxyEntity cBlk = new crawlAcDbProxyEntity(pxy);

                    result = jsonHelper.To <crawlAcDbProxyEntity>(cBlk);

                    DocumentFromBlockOrProxy(id_platf, result);
                }
                else if (id_platf.ObjectClass.Name == "AcDbSolid")
                {//Солид 2Д
                    Solid solid = (Solid)ent;


                    crawlAcDbSolid cSld = new crawlAcDbSolid(solid);

                    result = jsonHelper.To <crawlAcDbSolid>(cSld);
                }

                /*
                 *
                 *
                 * else if (id_platf.ObjectClass.Name == "AcDbLeader")
                 * {  //Выноска Autocad
                 * Leader ld = (Leader)ent;
                 *
                 * if (ld.EndPoint.Z != 0 || ld.StartPoint.Z != 0)
                 * {
                 * //ed.WriteMessage("DEBUG: Преобразован объект: Выноска Autocad");
                 *
                 * ld.EndPoint = new Point3d(ld.EndPoint.X, ld.EndPoint.Y, 0);
                 * ld.StartPoint = new Point3d(ld.StartPoint.X, ld.StartPoint.Y, 0);
                 *
                 * result = true;
                 * };
                 *
                 * }
                 * /*
                 * else if (id_platf.ObjectClass.Name == "AcDbPolygonMesh")
                 * {
                 * BUG: В платформе нет API для доступа к вершинам сетей AcDbPolygonMesh и AcDbPolygonMesh и AcDbSurface
                 *
                 * }
                 * else if (id_platf.ObjectClass.Name == "AcDbSolid")
                 * {
                 * BUG: Чтобы плющить Solid-ы нужны API функции 3d
                 * }
                 * else if (id_platf.ObjectClass.Name == "AcDbRegion")
                 * {
                 * Region rgn = ent as Region;
                 * BUG: нет свойств у региона
                 * }
                 *
                 */
                else
                {
                    //Если объект не входит в число перечисленных типов,
                    //то выводим в командную строку класс этого необработанного объекта

                    cDebug.WriteLine("Не могу обработать тип объекта: " + id_platf.ObjectClass.Name);
                }
            }
            catch (System.Exception ex)
            {
                //Если что-то сломалось, то в командную строку выводится ошибка
                cDebug.WriteLine("Не могу преобразовать - ошибка: " + ex.Message);
            };

            //Возвращаем значение функции
            return(result);
        }