Ejemplo n.º 1
0
        public void сreate(LandParcel parcel, double scaleTable)
        {
            LandParcel parcelСombinedLimiting = ServiceTable.СombinedLimiting(parcel);

            string titleTable = ServiceTable.ReplaceValueCodeInTitle(parcelСombinedLimiting, this.Setting);

            foreach (AcDb.DBObject obj in ServiceTable.GetCapTables(titleTable, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetBoundTable(parcelСombinedLimiting.Limiting.Count, this.Setting.TextHeight * 6, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetDataTableLimiting(parcelСombinedLimiting, this.Setting))
            {
                objects.Add(obj);
            }

            string nameBlockTable = ServiceBlockElements.CreateBlock(this.objects, this.Setting.KeyTable);

            ServiceBlockElements.ManualInsertBlock(nameBlockTable, scaleTable);
            objects = new AcDb.DBObjectCollection();
        }
Ejemplo n.º 2
0
        private _Db.DBObjectCollection getGeometry()
        {
            _Db.DBObjectCollection geometry = new _Db.DBObjectCollection();

            _Ed.PromptSelectionOptions opts = new _Ed.PromptSelectionOptions();
            opts.MessageForAdding = "\nSelect Geometry: ";
            _Ed.PromptSelectionResult userSelection = _c.doc.Editor.GetSelection(opts);
            if (userSelection.Status != _Ed.PromptStatus.OK)
            {
                throw new DMTException("[ERROR] Geometry - cancelled");
            }

            _Ed.SelectionSet selectionSet = userSelection.Value;

            foreach (_Ed.SelectedObject currentObject in selectionSet)
            {
                if (currentObject == null)
                {
                    continue;
                }

                _Db.Entity currentEntity = _c.trans.GetObject(currentObject.ObjectId, _Db.OpenMode.ForRead) as _Db.Entity;
                if (currentEntity == null)
                {
                    continue;
                }

                if (currentEntity is _Db.Curve)
                {
                    geometry.Add(currentEntity);
                }
            }

            return(geometry);
        }
Ejemplo n.º 3
0
        ///<summary>
        /// Get the centroid of a Region.
        ///</summary>
        ///<param name="cur">An optional curve used to define the region.</param>
        ///<returns>A nullable Point3d containing the centroid of the Region.</returns>
        public static _AcGe.Point3d? GetCentroid(this _AcDb.Region reg, _AcDb.Curve cur = null)
        {
            if (cur == null)
            {
                var idc = new _AcDb.DBObjectCollection();
                reg.Explode(idc);
                if (idc.Count == 0)
                {
                    return(null);
                }
                cur = idc[0] as _AcDb.Curve;
            }

            if (cur == null)
            {
                return(null);
            }

            var cs = cur.GetPlane().GetCoordinateSystem();
            var o  = cs.Origin;
            var x  = cs.Xaxis;
            var y  = cs.Yaxis;

            var a  = reg.AreaProperties(ref o, ref x, ref y);
            var pl = new _AcGe.Plane(o, x, y);

            return(pl.EvaluatePoint(a.Centroid));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Створює коллекцію лінійних обектів таблиці.
        /// </summary>
        /// <param name="numberRows">Кількість рядків таблиці.</param>
        /// <param name="stepRows">Крок рядків таблиці.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить лінійні обекти  таблиці.
        /// </returns>

        internal static AcDb.DBObjectCollection GetBoundTable(int numberRows, double stepRows, SettingTable settingTable)
        {
            AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection();

            double hTable = settingTable.GetHeightTable(numberRows, stepRows) * -1;
            double wTable = settingTable.GetWidthTable();

            AcGe.Point2dCollection pointsBoundTable =
                new AcGe.Point2dCollection(new AcGe.Point2d[]
            {
                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(0, 0)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(wTable, 0)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(wTable, hTable)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(0, hTable))
            });

            objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsBoundTable, true));

            AcGe.Point2dCollection pointsLine =
                new AcGe.Point2dCollection(new AcGe.Point2d[]
            {
                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(wTable, settingTable.GetHeightCapTable() * -1)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(0, settingTable.GetHeightCapTable() * -1))
            });

            objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsLine, false));

            double widthCur = 0;

            for (int i = 0; i < settingTable.Columns.Count - 1; i++)
            {
                ColumnTable value = settingTable.Columns.ToArray()[i];
                widthCur  += value.Width;
                pointsLine =
                    new AcGe.Point2dCollection(new AcGe.Point2d[]
                {
                    settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                    .Add(new AcGe.Vector2d(widthCur, 0)),

                    settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                    .Add(new AcGe.Vector2d(widthCur, hTable))
                });
                objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsLine, false));
            }

            return(objects);
        }
Ejemplo n.º 5
0
        private void ExplodeBlocks(_AcDb.Database db, List <_AcDb.ObjectId> allXrefsInMs, List <_AcDb.ObjectId> newlyCreatedObjects, bool deleteRef, bool deleteBtr)
        {
            log.Debug("ExplodeXRefs");
            using (_AcDb.Transaction tr = _TransMan.StartTransaction())
            {
                _AcDb.BlockTable bt = (_AcDb.BlockTable)tr.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead);

                _AcDb.BlockTableRecord btr = (_AcDb.BlockTableRecord)tr.GetObject(_AcDb.SymbolUtilityServices.GetBlockModelSpaceId(db), _AcDb.OpenMode.ForWrite);


                foreach (var oid in allXrefsInMs)
                {
                    _AcDb.DBObjectCollection objs  = new _AcDb.DBObjectCollection();
                    _AcDb.BlockReference     block = (_AcDb.BlockReference)tr.GetObject(oid, _AcDb.OpenMode.ForRead);
                    log.DebugFormat(CultureInfo.CurrentCulture, "Explode von Block '{0}'.", block.Name);
                    block.Explode(objs);
                    log.DebugFormat(CultureInfo.CurrentCulture, "Block enthält {0} Entities.", objs.Count);
                    _AcDb.ObjectId blockRefTableId = block.BlockTableRecord;


                    foreach (_AcDb.DBObject obj in objs)
                    {
                        _AcDb.Entity ent = (_AcDb.Entity)obj;
                        btr.AppendEntity(ent);
                        tr.AddNewlyCreatedDBObject(ent, true);

                        newlyCreatedObjects.Add(ent.ObjectId);
                    }

                    if (deleteRef)
                    {
                        log.DebugFormat(CultureInfo.CurrentCulture, "Lösche Block '{0}'.", block.Name);
                        block.UpgradeOpen();
                        block.Erase();
                    }

                    if (deleteBtr)
                    {
                        log.DebugFormat("DeleteBtr");
                        // funkt nicht -> xref würde gelöscht
                        var bd = (_AcDb.BlockTableRecord)tr.GetObject(blockRefTableId, _AcDb.OpenMode.ForWrite);
                        bd.Erase();
                        log.DebugFormat("Endof DeleteBtr");
                    }
                }
                tr.Commit();
            }
        }
Ejemplo n.º 6
0
        static public GeometryBase ToRhino(this _OdDb.Entity ent)
        {
            if (ent is _OdDb.Curve curve)
            {
                var geometry = curve.ToRhino();
                if (geometry != null)
                {
                    return(geometry);
                }
            }
            var aObj = new _OdDb.DBObjectCollection()
            {
                ent
            };
            string tmpPath = Path.Combine(Path.GetTempPath(), "BricsCAD", "torhino.3dm");

            if (_OdRx.ErrorStatus.OK != Bricscad.Rhino.RhinoUtilityFunctions.ExportRhinoFile(aObj, tmpPath))
            {
                return(null);
            }
            aObj.Dispose();
            return(ExtractGeometryFromFile(tmpPath));
        }
Ejemplo n.º 7
0
        public static string CreateBlock(
            AcDb.DBObjectCollection blockElements,
            string nameBlock)
        {
            using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
            {
                AcDb.BlockTable blockTable   = tr.GetObject(db.BlockTableId, AcDb.OpenMode.ForRead) as AcDb.BlockTable;
                string          oldNameBlock = nameBlock;
                int             iNameBlock   = 0;
mark_reNameBlock:
                if (blockTable.Has(nameBlock))
                {
                    iNameBlock++;
                    nameBlock = oldNameBlock + iNameBlock.ToString("_000");
                    goto mark_reNameBlock;
                }


                AcDb.BlockTableRecord blockTableRecord = new AcDb.BlockTableRecord
                {
                    Name = nameBlock
                };
                blockTable.UpgradeOpen();
                AcDb.ObjectId btrId = blockTable.Add(blockTableRecord);
                tr.AddNewlyCreatedDBObject(blockTableRecord, true);

                foreach (AcDb.Entity ent in blockElements)
                {
                    blockTableRecord.AppendEntity(ent);
                    tr.AddNewlyCreatedDBObject(ent, true);
                }

                tr.Commit();
            }

            return(nameBlock);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Створює коллекцію мультітекстових обектів заголовку таблиці та заголовків колонок таблиці.
        /// </summary>
        /// <param name="titleTable">Заголовок таблиці.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить мультитекстові обекти заголовку таблиці та заголовків колонок таблиці
        /// </returns>

        internal static AcDb.DBObjectCollection GetCapTables(string titleTable, SettingTable settingTable)
        {
            AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection();

            AcDb.MText   textValue;
            AcGe.Point3d insertPoint = AcGe.Point3d.Origin;

            /*Заголовок таблиці*/
            textValue                   = new AcDb.MText();
            textValue.TextHeight        = settingTable.TextHeight;
            textValue.LineSpaceDistance = settingTable.TextHeight * 0.7;
            textValue.Attachment        = AcDb.AttachmentPoint.BottomCenter;
            textValue.Contents          = titleTable;
            textValue.Location          = settingTable.BasePointDrawing
                                          .Add(new AcGe.Vector3d(settingTable.GetWidthTable() / 2, settingTable.TextHeight, 0));
            objects.Add(textValue);

            /*Заголовоки колонок таблиці*/
            double colWidth = 0;

            foreach (ColumnTable value in settingTable.Columns)
            {
                colWidth   += value.Width;
                insertPoint = new AcGe.Point3d(colWidth - value.Width / 2, settingTable.TextHeight / 2 * -1, 0);

                textValue                   = new AcDb.MText();
                textValue.TextHeight        = settingTable.TextHeight;
                textValue.LineSpaceDistance = settingTable.TextHeight * 2;
                textValue.Attachment        = AcDb.AttachmentPoint.TopCenter;
                textValue.Contents          = value.Name;
                textValue.Location          = settingTable.BasePointDrawing.Add(insertPoint.GetAsVector());

                objects.Add(textValue);
            }
            return(objects);
        }
Ejemplo n.º 9
0
        public void run()
        {
            _Db.DBObjectCollection polys = getGeometry();
            if (polys.Count == 0)
            {
                throw new DMTException("Valida tuleb polyline tüüpi objekte");
            }

            try
            {
                _Db.Region  reg    = createRegion(polys);
                _Ge.Point3d center = getCenter(reg);

                string X = center.X.ToString("G").Replace(",", ".");
                string Y = center.Y.ToString("G").Replace(",", ".");

                write("Centroid: " + X + "," + Y);
                createBlock(center);
            }
            catch
            {
                throw new DMTException("Vigane geomeetria");
            }
        }
Ejemplo n.º 10
0
        private _Db.Region createRegion(_Db.DBObjectCollection polys)
        {
            _Db.DBObjectCollection regions = new _Db.DBObjectCollection();
            regions = _Db.Region.CreateFromCurves(polys);

            double area  = 0;
            int    index = 0;

            if (regions.Count > 1)
            {
                for (int i = 0; i < regions.Count; i++)
                {
                    _Db.Region cur = regions[i] as _Db.Region;
                    if (area < cur.Area)
                    {
                        index = i;
                        area  = cur.Area;
                    }
                }
            }


            _Db.Region bigRegion = regions[index] as _Db.Region;

            for (int i = 0; i < regions.Count; i++)
            {
                if (i == index)
                {
                    continue;
                }
                _Db.Region cur = regions[i] as _Db.Region;
                bigRegion.BooleanOperation(_Db.BooleanOperationType.BoolSubtract, cur);
            }

            return(bigRegion);
        }
Ejemplo n.º 11
0
        public void сreate(LandParcel polygon, double scale)
        {
            string titleTable = ServiceTable.ReplaceValueCodeInTitle(polygon, this.Setting);

            foreach (AcDb.DBObject obj in ServiceTable.GetCapTables(titleTable, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetBoundTable(polygon.Points.Count + 1, this.Setting.TextHeight * 2, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetDataTableStakeOutParcelPoints(polygon, this.Setting))
            {
                objects.Add(obj);
            }

            string nameBlockTable = ServiceBlockElements.CreateBlock(this.objects, this.Setting.KeyTable);

            ServiceBlockElements.ManualInsertBlock(nameBlockTable, scale);
            objects = new AcDb.DBObjectCollection();
        }
Ejemplo n.º 12
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.º 13
0
        /// <summary>
        /// Створює коллекцію текстових обектів значень данних таблиці виносу внатуру меж земельної ділянки.
        /// </summary>
        /// <param name="polygon">Земельна ділянка.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        ///  Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці виносу внатуру меж земельної ділянки.
        /// </returns>
        internal static AcDb.DBObjectCollection GetDataTableStakeOutParcelPoints(LandParcel polygon, SettingTable settingTable)
        {
            List <StakeOutParcelPoint> stakeoutPoints = polygon.StakeOutParcelPoints;

            //stakeoutPoints.Sort((x, y) => y.PointStation.Name.CompareTo(x.PointStation.Name));

            AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection();

            AcDb.DBText  textValue;
            AcGe.Point3d insertPoint;

            //AcGe.Point2d backPoint, stationPoint, parcelPoint;

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

            int index = -1;

            foreach (StakeOutParcelPoint stakeoutPoint in stakeoutPoints)
            {
                index++;
                double colWidth = 0;
                heightTable += settingTable.TextHeight * 2 * index;

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

                    insertPoint = new AcGe.Point3d();
                    insertPoint = new AcGe.Point3d
                                  (
                        colWidth - col.Width / 2,
                        (settingTable.GetHeightCapTable() + (index + 1) * settingTable.TextHeight * 2) * -1,
                        0
                                  );

                    textValue = new AcDb.DBText();

                    textValue.Height         = settingTable.TextHeight;
                    textValue.Justify        = AcDb.AttachmentPoint.BottomCenter;
                    textValue.Position       = settingTable.BasePointDrawing.Add(insertPoint.GetAsVector());
                    textValue.AlignmentPoint = textValue.Position;

                    if (col.Format.IndexOf("Number") > -1)
                    {
                        textValue.TextString = stakeoutPoint.Name;
                    }
                    else if (col.Format.IndexOf("X") > -1)
                    {
                        textValue.TextString = stakeoutPoint.Coordinates.X.ToString("0.00");
                    }
                    else if (col.Format.IndexOf("Y") > -1)
                    {
                        textValue.TextString = stakeoutPoint.Coordinates.Y.ToString("0.00");
                    }
                    else if (col.Format.IndexOf("LengthLine") > -1)
                    {
                        textValue.TextString = stakeoutPoint.Distance.ToString("0.00");
                    }
                    else if (col.Format.IndexOf("DirAngle") > -1)
                    {
                        textValue.TextString = stakeoutPoint.DirAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds);
                    }
                    else if (col.Format.IndexOf("InnerAngle") > -1)
                    {
                        textValue.TextString = stakeoutPoint.LeftlAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds);
                    }
                    else if (col.Format.IndexOf("BasePoints_dirAngle") > -1)
                    {
                        textValue.TextString = stakeoutPoint.PointStation.Name;
                    }
                    else if (col.Format.IndexOf("BasePoints_innerAngle") > -1)
                    {
                        textValue.TextString = stakeoutPoint.PointStation.Name
                                               + " -> "
                                               + stakeoutPoint.PointOrientation.Name;
                    }
                    else
                    {
                        textValue.TextString = "None";
                    }

                    textValue.TextString = textValue.TextString.Replace(",", ".");
                    textValue.TextString = FormatAngleValue(textValue.TextString);

                    objects.Add(textValue);
                }
            }

            return(objects);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Створює коллекцію текстових обектів значень данних таблиці межі земельної ділянки.
        /// </summary>
        /// <param name="polygon">Ділянка, що є вихідною для таблиці.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        ///  Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці межі земельної ділянки.
        /// </returns>

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

            AcDb.DBText  textValue;
            AcGe.Point3d insertPoint;

            AcGe.Point2d backPoint, currentPoint, frontPoint;

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

            for (int index = 0; index <= polygon.Points.Count; index++)//(Point2d point in polygon.Points)
            {
                double colWidth = 0;
                heightTable += settingTable.TextHeight * 2 * index;

                if (index == 0)
                {
                    backPoint    = polygon.Points.ToArray()[polygon.Points.Count - 1];
                    currentPoint = polygon.Points.ToArray()[index];
                    frontPoint   = polygon.Points.ToArray()[index + 1];
                }
                else if (index == polygon.Points.Count - 1)
                {
                    backPoint    = polygon.Points.ToArray()[index - 1];
                    currentPoint = polygon.Points.ToArray()[index];
                    frontPoint   = polygon.Points.ToArray()[0];
                }
                else if (index == polygon.Points.Count)
                {
                    backPoint    = polygon.Points.ToArray()[index - 1];
                    currentPoint = polygon.Points.ToArray()[0];
                    frontPoint   = polygon.Points.ToArray()[1];
                }
                else
                {
                    backPoint    = polygon.Points.ToArray()[index - 1];
                    currentPoint = polygon.Points.ToArray()[index];
                    frontPoint   = polygon.Points.ToArray()[index + 1];
                }

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

                    insertPoint = new AcGe.Point3d();
                    insertPoint = new AcGe.Point3d(colWidth - col.Width / 2, (settingTable.GetHeightCapTable() + (index + 1) * settingTable.TextHeight * 2) * -1, 0);

                    textValue = new AcDb.DBText();

                    textValue.Height         = settingTable.TextHeight;
                    textValue.Justify        = AcDb.AttachmentPoint.BottomCenter;
                    textValue.Position       = settingTable.BasePointDrawing.Add(insertPoint.GetAsVector());
                    textValue.AlignmentPoint = textValue.Position;

                    if (col.Format.IndexOf("Number") > -1)
                    {
                        if (index == polygon.Points.Count)
                        {
                            textValue.TextString = "1";
                        }
                        else
                        {
                            textValue.TextString = Math.Abs(index + 1).ToString();
                        }
                    }
                    else if (col.Format.IndexOf("X") > -1)
                    {
                        textValue.TextString = currentPoint.X.ToString("0.00");
                    }
                    else if (col.Format.IndexOf("Y") > -1)
                    {
                        textValue.TextString = currentPoint.Y.ToString("0.00");
                    }
                    else if (col.Format.IndexOf("LengthLine") > -1)
                    {
                        if (index < polygon.Points.Count)
                        {
                            textValue.Position       = textValue.Position.Add(new AcGe.Vector3d(0, settingTable.TextHeight * -1, 0));
                            textValue.AlignmentPoint = textValue.Position;
                            textValue.TextString     = currentPoint.GetDistanceTo(frontPoint).ToString("0.00");
                        }
                    }
                    else if (col.Format.IndexOf("DirAngle") > -1)
                    {
                        if (index < polygon.Points.Count)
                        {
                            textValue.Position       = textValue.Position.Add(new AcGe.Vector3d(0, settingTable.TextHeight * -1, 0));
                            textValue.AlignmentPoint = textValue.Position;
                            double angle = ServiceGeodesy.GetDirAngle(currentPoint, frontPoint);
                            textValue.TextString = AcRx.Converter.AngleToString(angle, AcRx.AngularUnitFormat.DegreesMinutesSeconds, 3);
                        }
                    }
                    else if (col.Format.IndexOf("InnerAngle") > -1)
                    {
                        double angle = ServiceGeodesy.GetRightAngle(backPoint, currentPoint, frontPoint);
                        textValue.TextString = AcRx.Converter.AngleToString(angle, AcRx.AngularUnitFormat.DegreesMinutesSeconds, 3);
                    }
                    else
                    {
                        textValue.TextString = "None";
                    }

                    textValue.TextString = textValue.TextString.Replace(",", ".");

                    for (int i = 0; i < 10; i++)
                    {
                        textValue.TextString = textValue.TextString
                                               .Replace("°" + i.ToString() + "'", "°" + i.ToString("00") + "'");
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        textValue.TextString = textValue.TextString
                                               .Replace("'" + i.ToString() + "\"", "'" + i.ToString("00") + "\"");
                    }

                    objects.Add(textValue);
                }
            }

            return(objects);
        }
Ejemplo n.º 15
0
        private List <_Ge.Point3d> handle(_Db.Entity ent)
        {
            List <_Ge.Point3d> points = new List <_Ge.Point3d>();

            if (ent == null)
            {
                return(points);
            }


            if (ent is _Db.Curve && !(ent is _Db.Polyline || ent is _Db.Polyline2d || ent is _Db.Polyline3d))
            {
                try
                {
                    _Db.Curve cur = ent as _Db.Curve;

                    int segs = 3; //(ent is Line ? 3 : 20);

                    double param = cur.EndParam - cur.StartParam;

                    for (int i = 0; i < segs; i++)
                    {
                        try
                        {
                            _Ge.Point3d pt = cur.GetPointAtParameter(cur.StartParam + (i * param / (segs - 1)));
                            points.Add(pt);
                        }
                        catch { }
                    }
                }
                catch { }
            }
            else
            {
                _Db.DBObjectCollection objectCollection = new _Db.DBObjectCollection();
                try
                {
                    ent.Explode(objectCollection);
                    if (objectCollection.Count > 0)
                    {
                        foreach (_Db.DBObject bid in objectCollection)
                        {
                            _Db.Entity ent2 = bid as _Db.Entity;
                            if (ent2 != null && ent2.Visible)
                            {
                                List <_Ge.Point3d> currentPoints = handle(ent2);
                                points.AddRange(currentPoints);
                            }
                            bid.Dispose();
                        }
                    }
                }
                catch { }
            }

            if (ent is _Db.Circle)
            {
                _Db.Circle         circle       = ent as _Db.Circle;
                List <_Ge.Point3d> circlePoints = getCirclePoints(circle);
                points.AddRange(circlePoints);
            }
            else if (ent is _Db.Arc)
            {
                _Db.Arc            arc       = ent as _Db.Arc;
                List <_Ge.Point3d> arcPoints = getArcPoints(arc);
                points.AddRange(arcPoints);
            }

            return(points);
        }