示例#1
1
        public void TestDrawRec()
        {
            Matrix3d ucs = CoordinateSystem.CoordinateTools.GetCurrentUcs();

            PromptPointOptions ppo = new PromptPointOptions("\nУкажите начальную точку");

            PromptPointResult ppr = Tools.GetAcadEditor().GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return;
            }

            Drawing.PolyGrid grid = new Drawing.PolyGrid(ppr.Value, 100, 50, ucs);

            /*ppo = new PromptPointOptions("\nУкажите конечную точку");
             * ppo.UseBasePoint = true;
             * ppo.BasePoint = grid.Origin;
             * ppo.UseDashedLine = true;
             *
             * ppr = Tools.GetAcadEditor().GetPoint(ppo);
             * if (ppr.Status != PromptStatus.OK)
             *  return;*/

            //grid.Display(ppr.Value);

            if (grid.JigDraw() == PromptStatus.OK)
            {
                return;
            }
        }
        public static void DoIt()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions opts = new PromptPointOptions("\nEnter Ellipse Center Point:");
            PromptPointResult res = ed.GetPoint(opts);

            Vector3d x = Application.DocumentManager.MdiActiveDocument.Database.Ucsxdir;
            Vector3d y = Application.DocumentManager.MdiActiveDocument.Database.Ucsydir;
            Vector3d NormalVec = x.CrossProduct(y);

            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;

            //Create Ellipsejig
            EllipseJig jig = new EllipseJig(res.Value,NormalVec.GetNormal());
            //first call drag to get the major axis
            jig.setPromptCounter(0);
            Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig);
            // Again call drag to get minor axis
            jig.setPromptCounter(1);
            Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig);

            //Append entity.
            using (Transaction myT = tm.StartTransaction())
            {
                BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId,OpenMode.ForRead,false);
                BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false);
                btr.AppendEntity(jig.GetEntity());
                tm.AddNewlyCreatedDBObject(jig.GetEntity(),true);
                myT.Commit();
            }
        }
示例#3
0
        Point()
        {
            m_db = Utils.Db.GetCurDwg();

            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            PromptPointOptions prPtOpt = new PromptPointOptions("\nPoint");
            PromptPointResult  prPtRes = ed.GetPoint(prPtOpt);

            if (prPtRes.Status != PromptStatus.OK)
            {
                return;
            }

            using (DBPoint point = new DBPoint()) {
                point.Position = prPtRes.Value;
                Utils.Db.TransformToWcs(point, m_db);

                // TBD: not sure why, but the call to set the EcsRotation must come
                // after we do the TransformToWcs().  Need to investigate whether that
                // is a bug or intended behavior.
                point.EcsRotation = GetDimHorizRotation();
                Utils.SymTbl.AddToCurrentSpaceAndClose(point, m_db);
            }
        }
示例#4
0
        getPoint(string strPrompt, Point3d pnt3d, out bool escape)
        {
            escape = true;
            Point3d           pnt3dX = Pub.pnt3dO;
            Editor            ED     = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointResult PPR    = null;

            PromptPointOptions PPO = new PromptPointOptions(strPrompt);

            PPO.AllowNone = true;
            if (pnt3d != Pub.pnt3dO)
            {
                PPO.UseBasePoint  = true;
                PPO.BasePoint     = pnt3d;
                PPO.UseDashedLine = true;
            }

            PPR = ED.GetPoint(PPO);
            switch (PPR.Status)
            {
            case PromptStatus.Cancel:
            case PromptStatus.Other:
            case PromptStatus.None:
                break;

            case PromptStatus.OK:
                pnt3dX = PPR.Value;
                escape = false;
                break;
            }
            return(pnt3dX);
        }
示例#5
0
        private List <Point3d> GetPointCollection()
        {
            var returnvalue = new List <Point3d>();
            var pOpt        = new PromptPointOptions(Environment.NewLine + "Select Point")
            {
                AllowNone = true
            };
            var result = Active.Editor.GetPoint(pOpt);

            if (result.Status != PromptStatus.OK || result.Status == PromptStatus.None)
            {
                return(null);
            }

            returnvalue.Add(result.Value);

            pOpt.Message      = Environment.NewLine + "Select label pos:";
            pOpt.UseBasePoint = true;
            pOpt.BasePoint    = result.Value;
            var result1 = Active.Editor.GetPoint(pOpt);

            if (result1.Status != PromptStatus.OK || result.Status == PromptStatus.None)
            {
                return(null);
            }

            returnvalue.Add(result1.Value);

            return(returnvalue);
        }
示例#6
0
        public void CreateAngleXLineCommand()
        {
            PromptPointOptions ppo = new PromptPointOptions("\nPick Point");
            PromptPointResult  ppr = GLOBAL.CurrentEditor.GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return;
            }

            PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter Grade (%)");
            PromptDoubleResult  pdr = GLOBAL.CurrentEditor.GetDouble(pdo);

            if (pdr.Status != PromptStatus.OK)
            {
                return;
            }
            // calculate second point
            Point3d secondPoint = Helper.Point3dHelper.Offset(ppr.Value, 100, pdr.Value, 0);
            Xline   xline       = new Xline()
            {
                BasePoint = ppr.Value, UnitDir = new Vector3d(secondPoint.X - ppr.Value.X, secondPoint.Y - ppr.Value.Y, secondPoint.Z - ppr.Value.Z)
            };
            CompositeFigure cg = new CompositeFigure();

            cg.Children.Add(xline);
            cg.Append(GLOBAL.CurrentDocument);
        }
示例#7
0
        private void CommandSelectCrossingWindow()
        {
            if (Application.DocumentManager.MdiActiveDocument == null)
            {
                return;
            }
            Document           mdiActiveDocument  = Application.DocumentManager.MdiActiveDocument;
            Editor             editor             = mdiActiveDocument.Editor;
            PromptPointOptions promptPointOptions = new PromptPointOptions(AfaStrings.MSG_SELECT_FIRSTCORNER);
            PromptPointResult  point = editor.GetPoint(promptPointOptions);

            if (point.Status != (PromptStatus)5100)
            {
                editor.WriteMessage(AfaStrings.MSG_SELECTCORNER_ERROR);
                return;
            }
            PromptCornerOptions promptCornerOptions = new PromptCornerOptions(AfaStrings.MSG_SELECT_SECONDCORNER, point.Value);
            PromptPointResult   corner = editor.GetCorner(promptCornerOptions);

            if (corner.Status != (PromptStatus)5100)
            {
                editor.WriteMessage(AfaStrings.MSG_SELECTCORNER_ERROR);
                return;
            }
            PromptSelectionResult promptSelectionResult = editor.SelectCrossingWindow(point.Value, corner.Value);

            if (promptSelectionResult.Status == (PromptStatus)(-5002))
            {
                editor.WriteMessage(AfaStrings.CommandCancelled);
                return;
            }
            PromptStatus arg_C3_0 = promptSelectionResult.Status;
        }
示例#8
0
        public void SoftInsulationStart()
        {
            var promptPointOptions = new PromptPointOptions("\nSelect First Point or [3points/4points/Polyline/Block]",
                                                            "3points 4points Polyline Block");
            var ppr = _editorHelper.PromptForPoint(promptPointOptions);

            if (ppr.Status == PromptStatus.Keyword || ppr.Status == PromptStatus.OK)
            {
                switch (ppr.StringResult)
                {
                case "3points":
                    DrawInsulationOnThreePoints();
                    break;

                case "4points":
                    DrawInsulationOnFourPoints();
                    break;

                case "Polyline":
                    DrawInsulationOnPolyline();
                    break;

                case "Block":
                    ImportInsulationBlock();
                    break;

                default:
                    DrawInsulationOnTwoPointsTwoHeights(ppr);
                    break;
                }
            }
            Logger.Info(System.Reflection.MethodBase.GetCurrentMethod().Name);
        }
        public bool GetPoint(string prompt, Point3d basePoint, out Point3d pt)
        {
            Editor             ed  = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions ppo = new PromptPointOptions(prompt);

            ppo.BasePoint    = basePoint;
            ppo.UseBasePoint = true;
            PromptPointResult ppr = ed.GetPoint(ppo);

            if (ppr.Status == PromptStatus.OK)
            {
                pt = ppr.Value;

                // 变换到世界坐标系
                Matrix3d mat = ed.CurrentUserCoordinateSystem;
                pt.TransformBy(mat);

                return(true);
            }
            else
            {
                pt = new Point3d();
                return(false);
            }
        }
示例#10
0
        private PromptStatus GetDistance(string message1, string message2, out double length, bool allowEmpty)
        {
            Editor             ed   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions opt1 = new PromptPointOptions(message1);

            opt1.AllowNone = allowEmpty;
            PromptPointResult res1 = ed.GetPoint(opt1);

            if (res1.Status == PromptStatus.OK)
            {
                PromptDistanceOptions opt2 = new PromptDistanceOptions(message2);
                opt2.AllowNone    = allowEmpty;
                opt2.BasePoint    = res1.Value;
                opt2.UseBasePoint = true;
                PromptDoubleResult res2 = ed.GetDistance(opt2);
                if (res2.Status == PromptStatus.OK)
                {
                    length = res2.Value;
                    return(PromptStatus.OK);
                }
            }

            length = 0;
            return(PromptStatus.Cancel);
        }
示例#11
0
        public static double[] GetSize(out bool hasInput)
        {
            hasInput = true;
            double[] widthHeight = new double[] { 0.00, 0.00 }; //double[] width_Height_ConcrPress = new double[] { 0.00, 0.00, 0.00 };


            Document           acDoc = Application.DocumentManager.MdiActiveDocument;
            PromptPointResult  pPtRes;
            PromptPointOptions pPtOpts     = new PromptPointOptions("");
            Point3d            inputValues = new Point3d(0.00, 0.00, 0.00);



            pPtOpts.Message = "\nEnter panel width[mm], height[mm] : "; //pPtOpts.Message = "\nEnter width[mm], height[mm], permissible fresh concrete pressure[kN/m2] : ";
            pPtRes          = acDoc.Editor.GetPoint(pPtOpts);
            inputValues     = pPtRes.Value;

            widthHeight[0] = inputValues.X;
            widthHeight[1] = inputValues.Y;
            //width_Height_ConcrPress[2] = inputValues.Z;


            if (pPtRes.Status == PromptStatus.Cancel)
            {
                hasInput = false;
            }

            return(widthHeight);
        }
示例#12
0
        public void FDOSelectCrossingPoint()
        {
            Core.ClearImpliedSelection();

            PromptPointOptions pnt_opts = new PromptPointOptions("Укажите точку для выбора объктов карты (FDO) (Esc или Enter чтобы отказаться):");

            pnt_opts.AllowNone = true;

            PromptPointResult point_result = Core.current_editor.GetPoint(pnt_opts);             // выбор точки

            if (point_result.Status == PromptStatus.OK)
            {
                PromptSelectionResult sel_result = Core.current_editor.SelectCrossingWindow(point_result.Value, point_result.Value);                 // выбор объектов
                if (sel_result.Status == PromptStatus.OK)
                {
                    // преобразование SelectionSet'а AutoCAD'а в выборку MgSelectionBase (только объекты FDO)
                    MgSelectionBase selection_base = AcMapFeatureEntityService.GetSelection(sel_result.Value);

                    // установка активной выборки
                    SelectionSet new_sel_set = AcMapFeatureEntityService.AddFeaturesToSelectionSet(null, selection_base);
                    Core.current_editor.SetImpliedSelection(new_sel_set);
                }
            }
            Core.WriteMessage("\n");
        }
        private void getYAxis_button_Click(object sender, EventArgs e)
        {
            this.Hide();

            PromptPointOptions ppo = new PromptPointOptions("\nУкажите первую точку определяющую ось Y");
            PromptPointResult ppr = Tools.GetAcadEditor().GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            Point3d firstYAxisPoint = ppr.Value;

            ppo = new PromptPointOptions("\nУкажите вторую точку определяющую ось Y");
            ppo.UseBasePoint = true;
            ppo.BasePoint = firstYAxisPoint;
            ppo.UseDashedLine = true;

            ppr = Tools.GetAcadEditor().GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            Point3d secondYAxisPoint = ppr.Value;

            _angle = CoordinateSystem.CoordinateTools.GetAngleFromUcsYAxis(secondYAxisPoint - firstYAxisPoint);

            Tools.GetActiveAcadDocument().Editor.UpdateScreen();

            this.Show();
        }
示例#14
0
        public void MyPickFirst() // This method can have any name
        {
            Editor             ed     = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions ptopts = new PromptPointOptions("选择打印窗体区域左上角点");

            ptopts.BasePoint     = new Point3d(1, 1, 1);
            ptopts.UseDashedLine = true;
            ptopts.Message       = "选择打印窗体区域左上角点";

            ed.PromptingForPoint += new PromptPointOptionsEventHandler(handle_promptPointOptions);
            ed.PromptedForPoint  += new PromptPointResultEventHandler(handle_promptPointResult);

            PromptPointResult ptRes = ed.GetPoint(ptopts);

            ed.PromptingForPoint -= new PromptPointOptionsEventHandler(handle_promptPointOptions);
            ed.PromptedForPoint  -= new PromptPointResultEventHandler(handle_promptPointResult);


            Point3d start = ptRes.Value;

            if (ptRes.Status == PromptStatus.Cancel)
            {
                ed.WriteMessage("将 (0,0,0) 作为打印窗体区域左上角点");
            }

            ptopts.Message = "选择打印窗体区域右下角";
            ptRes          = ed.GetPoint(ptopts);
            Point3d end = ptRes.Value;

            if (ptRes.Status == PromptStatus.Cancel)
            {
                ed.WriteMessage("将 (0,0,0) 作为打印窗体区域右下角");
            }
        }
示例#15
0
        public void LineParkingCommand()
        {
            Log.Info("Start Command GP-LineParking");
            // рисование линии парковки
            Document doc = Application.DocumentManager.MdiActiveDocument;

            if (doc == null)
            {
                return;
            }
            Database db = doc.Database;
            Editor   ed = doc.Editor;

            // запрос первой точки
            PromptPointOptions optFisrstPt = new PromptPointOptions("Укажите первую точку");

            optFisrstPt.Keywords.Add("Options");
            var resFirstPt = ed.GetPoint(optFisrstPt);

            if (resFirstPt.Status == PromptStatus.OK)
            {
                checkLayer(db);
                JigLineParking jigLineParking = new JigLineParking(resFirstPt.Value.TransformBy(ed.CurrentUserCoordinateSystem),
                                                                   LineParkingOptions.Instance);
                var jigRes = ed.Drag(jigLineParking);
                if (jigRes.Status == PromptStatus.OK && jigLineParking.Lines.Count > 0)
                {
                    // Добавление полилинии в чертеж.
                    using (var tr = db.TransactionManager.StartTransaction())
                    {
                        BlockTableRecord cs = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                        foreach (var line in jigLineParking.Lines)
                        {
                            line.SetDatabaseDefaults(db);
                            // слой
                            if (!string.IsNullOrWhiteSpace(LineParkingOptions.Instance.ParkingLineLayer))
                            {
                                line.Layer = LineParkingOptions.Instance.ParkingLineLayer;
                            }
                            cs.AppendEntity(line);
                            tr.AddNewlyCreatedDBObject(line, true);
                        }
                        tr.Commit();
                    }
                }
            }
            else if (resFirstPt.Status == PromptStatus.Keyword)
            {
                if (resFirstPt.StringResult == "Options")
                {
                    FormOptions formOpt = new FormOptions(LineParkingOptions.Instance);
                    if (Application.ShowModalDialog(formOpt) == System.Windows.Forms.DialogResult.OK)
                    {
                        LineParkingOptions.Save();
                    }
                    LineParkingCommand();
                }
            }
        }
        public static Point3d[] GetAxisVectorCmd(CoordinateSystem3d ucs)
        {
            PromptPointOptions ppo = new PromptPointOptions("\nУкажите первую точку положения оси/грани");

            ppo.Keywords.Add("Xaxis", "ОсьХ", "Ось Х", true, true);
            PromptPointResult ppr = Tools.GetAcadEditor().GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return(null);
            }

            ppo = new PromptPointOptions("\nУкажите вторую точку положения оси/грани");
            ppo.UseBasePoint  = true;
            ppo.BasePoint     = ppr.Value;
            ppo.UseDashedLine = true;
            ppr = Tools.GetAcadEditor().GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
            {
                return(null);
            }

            var res = new[] { ppo.BasePoint, ppr.Value };

            return(res);
        }
示例#17
0
        public static Point3d?getPoint(string msg)
        {
            Point3d? r     = null;
            Document acDoc = Application.DocumentManager.MdiActiveDocument;

            Editor             ed  = acDoc.Editor;
            PromptPointOptions ppo = new PromptPointOptions(msg);

            ppo.AllowNone = true;
            PromptPointResult ppr = null;

            while (true)
            {
                ppr = ed.GetPoint(ppo);
                if (ppr.Status == PromptStatus.Cancel)
                {
                    //ed.WriteMessage("\n命令被取消");
                    return(null);
                }
                else if (ppr.Status == PromptStatus.OK)
                {
                    break;
                }
                else if (ppr.Status == PromptStatus.None)
                {
                    return(null);
                }
            }
            r = ppr.Value;
            return(r);
        }
示例#18
0
        public void AutoNumerateCommand()
        {
            var ed        = Application.DocumentManager.MdiActiveDocument.Editor;
            var prefix    = ed.GetString(new PromptStringOptions("set prefix")).StringResult;
            var offsetOpt = new PromptIntegerOptions("Offset")
            {
                AllowNone     = false,
                AllowZero     = true,
                AllowNegative = false,
                DefaultValue  = 1
            };
            var offset  = ed.GetInteger(offsetOpt).Value;
            var pPtOpts = new PromptPointOptions("\ninsert point:");

            while (true)
            {
                var pPtRes = ed.GetPoint(pPtOpts);
                if (pPtRes.Status == PromptStatus.Cancel)
                {
                    break;
                }
                var position = pPtRes.Value;
                var text     = new DBText
                {
                    Position   = position,
                    TextString = string.Format("{0}{1}", prefix, offset)
                };
                Tools.DrawDBtext(text);
                offset          = offset + 1;
                pPtOpts.Message = "\ninsert next point:";
            }
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="H"></param>
        /// <param name="zMin"></param>
        void Slant(double H, PromptDoubleResult zMin)
        {
            Editor             ed  = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions p1O = new PromptPointOptions("\nPick slant first point:");
            PromptPointResult  p1  = ed.GetPoint(p1O);

            if (p1.Status != PromptStatus.OK)
            {
                return;
            }
            PromptPointOptions p2O = new PromptPointOptions("\nPick slant other point: ");

            p2O.UseBasePoint  = true;
            p2O.BasePoint     = p1.Value;
            p2O.UseDashedLine = true;
            PromptPointResult p2 = ed.GetPoint(p2O);

            if (p2.Status != PromptStatus.OK)
            {
                return;
            }

            Utils.Utils.Bresenham(p1.Value[0], p1.Value[1], p2.Value[0], p2.Value[1], H, zMin.Value);
            return;
        }
示例#20
0
        private Point3d GetPoint()
        {
            PromptPointOptions promptPointOptions = new PromptPointOptions("\n点取齿轮中心点位置或[过程演示(Y)/(N)]", "Y N");

            ((PromptCornerOptions)promptPointOptions).set_AllowNone(false);
            ((PromptOptions)promptPointOptions).get_Keywords().Add("D", "D", "设置延迟时间(D)", false, true);
            ((PromptOptions)promptPointOptions).get_Keywords().set_Default("N");
            PromptPointResult point = this.ed.GetPoint(promptPointOptions);

            if (((PromptResult)point).get_Status() == 5100)
            {
                return(point.get_Value());
            }
            if (((PromptResult)point).get_Status() == -5005)
            {
                if (((PromptResult)point).get_StringResult() == "D")
                {
                    this.delay  = this.GetInt("\n输入延迟时间", 200);
                    this.doDemo = "Y";
                    return(this.GetPoint());
                }
                this.doDemo = ((PromptResult)point).get_StringResult();
                this.delay  = 200;
                return(this.GetPoint());
            }
            this.doDemo = "N";
            return((Point3d)null);
        }
示例#21
0
        public static int getSide(List <Point3d> pnts3d)
        {
            int intSide            = 0;
            PromptPointOptions PPO = new PromptPointOptions("Select a location near the begin point of reference line and on the side to grade to.");
            PromptPointResult  PPR = null;

            try
            {
                PPR = SG_Utility.ed.GetPoint(PPO);
            }
            catch (Exception)
            {
                intSide = 0;
            }

            if (PPR.Status == PromptStatus.OK)
            {
                Point3d pnt3d = PPR.Value;

                if (pnt3d.isRightSide(pnts3d[0], pnts3d[1]))
                {
                    intSide = -1;
                }
                else
                {
                    intSide = 1;
                }
            }

            return(intSide);
        }
示例#22
0
        public static bool SpecifyWindow(out Point3d?pt1, out Point3d?pt2, Editor adocEd)
        {
            pt1 = null;
            pt2 = null;
            Point3d _pt1 = new Point3d();
            Point3d _pt2 = new Point3d();

            PromptPointOptions ppo = new PromptPointOptions("\n\tУкажите первый угол рамки: ");
            PromptPointResult  ppr = adocEd.GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return(false);
            }
            PromptCornerOptions pco = new PromptCornerOptions("\n\tУкажите второй угол рамки: ", ppr.Value);
            PromptPointResult   pcr = adocEd.GetCorner(pco);

            if (pcr.Status != PromptStatus.OK)
            {
                return(false);
            }
            _pt1 = ppr.Value;
            _pt2 = pcr.Value;
            if (_pt1.X == _pt2.X || _pt1.Y == _pt2.Y)
            {
                adocEd.WriteMessage("\nНеправильно указаны точки");
                return(false);
            }

            pt1 = _pt1;
            pt2 = _pt2;
            return(true);
        }
示例#23
0
        /// <summary> 在界面中选择一行点或者一列点,用来进行表格的单元格划分 </summary>
        private Point3d GetPointsFromUI(DocumentModifier docMdf, bool forRow, out bool continueSelect)
        {
            continueSelect = false;
            // 创建一个 TypedValue 数组,用于定义过滤条件
            TypedValue[] acTypValAr = new TypedValue[]
            {
                new TypedValue((int)DxfCode.Start, "TEXT"),
            };

            // 将过滤条件赋值给SelectionFilter对象
            SelectionFilter acSelFtr = new SelectionFilter(acTypValAr);

            //获取当前文档编辑器
            Editor ed  = docMdf.acActiveDocument.Editor;
            string msg = forRow ? "选择作为 行 分隔的点(至少2个) " : "选择作为 列 分隔的点(至少2个) ";

            var pao = new PromptPointOptions(message: $"\n{msg}");

            pao.AllowNone = true; // 允许用户直接按下回车或者右键,以退出 GetPoint() 方法,此时返回的 PromptPointResult.Status 为 None。

            // 请求在图形区域选择对象。 GetSelection() 会阻塞线程,直到用户在AutoCAD界面中选择对象完成、取消或者出错。
            PromptPointResult psr = ed.GetPoint(pao);

            // 输出文本所对应的数据
            if (psr.Status == PromptStatus.OK)
            {
                continueSelect = true;
                return(psr.Value);
            }
            else
            {
                continueSelect = false;
                return(default(Point3d));
            }
        }
示例#24
0
        static public void DoIt()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            //输入起点坐标
            PromptPointOptions opts = new PromptPointOptions("\nEnter Tunnel Start Point:");
            PromptPointResult  res  = ed.GetPoint(opts);

            if (res.Status == PromptStatus.Cancel)
            {
                return;
            }

            Point3d tmpPoint = res.Value;

            TagJig jig = new TagJig(tmpPoint, tmpPoint, tmpPoint);

            jig.setPromptCounter(0);
            PromptResult drag = ed.Drag(jig);

            jig.setPromptCounter(1);
            drag = ed.Drag(jig);

            Database db = Application.DocumentManager.MdiActiveDocument.Database;

            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
            var stdLn = (Tag)jig.GetEntity();

            stdLn.Text = "标注测试文字";

            Utils.AppendEntity(stdLn);
            stdLn.Dispose();
        }
示例#25
0
        /// <summary>
        /// Get 2 point which is 2 corner of a rectangle
        /// </summary>
        /// <param name="ed">Editor of active CAD document</param>
        /// <returns>2D Array of point 3D</returns>
        public static Point3d[] GetCorners()
        {
            Document ac = Application.DocumentManager.MdiActiveDocument;
            Editor   ed = ac.Editor;

            Point3d[]          result = new Point3d[2];
            PromptPointResult  prPntRes1;
            PromptPointOptions prPntOpts1 = new PromptPointOptions(
                "\nSpecify the first corner: \n"
                );

            // Set attributes for selection function
            prPntOpts1.AllowArbitraryInput = true;
            prPntOpts1.AllowNone           = false;
            prPntOpts1.LimitsChecked       = false;
            prPntRes1 = ed.GetPoint(prPntOpts1);

            if (prPntRes1.Status != PromptStatus.Cancel)
            {
                PromptPointResult   prPntRes2;
                PromptCornerOptions prCorOpts2 = new PromptCornerOptions(
                    "\nSpecify the opposite corner: \n",
                    prPntRes1.Value
                    );
                prPntRes2 = ed.GetCorner(prCorOpts2);

                if (prPntRes2.Status != PromptStatus.Cancel)
                {
                    result[0] = prPntRes1.Value;
                    result[1] = prPntRes2.Value;
                }
            }
            return(result);
        }
示例#26
0
        public void CreateReddit()
        {
            EntityData dimStyles = new EntityData();
            Document   doc       = Application.DocumentManager.MdiActiveDocument;
            Editor     ed;

            if (doc != null)
            {
                ed = doc.Editor;
                PromptStringOptions prmptStrOpt     = new PromptStringOptions("\n\n Type subreddit name. Do not include '/r/' ");
                PromptResult        prmpRes         = ed.GetString(prmptStrOpt);
                PromptPointOptions  prmptPtOptions  = new PromptPointOptions("\n\nPick insertion point....");
                PromptPointResult   result          = ed.GetPoint(prmptPtOptions);
                PromptCornerOptions prmptCnrOptions = new PromptCornerOptions("\n\n Click on bottom corner..", result.Value);
                PromptPointResult   prmptCnrResult;
                prmptCnrResult = ed.GetCorner(prmptCnrOptions);
                string chosenSubReddit = prmpRes.StringResult;
                RedditCAD.FormatRedditDim(dimStyles, result.Value, prmptCnrResult.Value);

                if (RedditCAD.PlotSubReddit(dimStyles, chosenSubReddit) == "FAILED")
                {
                    ed.WriteMessage("\n\nFAILED");
                }
            }
        }
示例#27
0
        /// <summary>
        /// Aligment text in current document
        /// </summary>
        /// <param name="alig"></param>
        public static void TextAligmentAction(Aligment alig)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            // Select DBText and MText
            List <string> oTp = new List <string>
            {
                "TEXT",
                "MTEXT"
            };
            ObjectIdCollection objIdColl = Utils.SelectionFilter(oTp, ed);

            if (objIdColl != null)
            {
                // Get base point
                Point3d            bPoint = new Point3d();
                PromptPointResult  pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("");
                pPtOpts.Message = "\nSpecify aligment point: ";
                pPtRes          = ed.GetPoint(pPtOpts);

                // Perform aligment
                if (pPtRes.Status == PromptStatus.OK)
                {
                    bPoint = pPtRes.Value;
                    Utils.AligmentText(db, objIdColl, alig, bPoint);
                }
            }
            else
            {
                ed.WriteMessage("\nNot found any text!\n");
            }
        }
示例#28
0
        //[Autodesk.AutoCAD.Runtime.CommandMethod("iCmd_DrawArrows", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)]
        public void DrawArrowsEx()
        {
            _ucs = CoordinateSystem.CoordinateTools.GetCurrentUcs();
            PromptPointOptions ppo = new PromptPointOptions("\nУкажите проектное положение");

            PromptPointResult ppr = Tools.GetAcadEditor().GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return;
            }

            /*Arrow arrow = new Arrow(ppr.Value, _ucs);
             * if (arrow.DrawJig() == PromptStatus.OK)
             * {
             *  var entities = arrow.Explode();
             *  foreach (Entity ent in entities)
             *  {
             *      Tools.AppendEntity(ent);
             *  }
             * }*/

            _insertPoint = ppr.Value;
            _arrow       = new Arrow(ppr.Value, _ucs);
            if (JigDraw() == PromptStatus.OK)
            {
                SaveToDatabase();
            }
        }
        public static Point3d?GetInsertPoint(Vector3d axisVector, Matrix3d ucs)
        {
            PromptPointOptions ppo = new PromptPointOptions("\nУкажите точку вставки/проектное положение");

            ppo.Keywords.Add("Perpendicular", "Перпендикуляр", "Перпендикуляр", true, true);
            ppo.Keywords.Add("Exit", "Выход", "Выход", true, true);
            ppo.AllowArbitraryInput = true;
            PromptPointResult ppr = Tools.GetAcadEditor().GetPoint(ppo);

            if (ppr.Status == PromptStatus.Keyword)
            {
                if (ppr.StringResult == "Exit")
                {
                    return(null);
                }
                if (ppr.StringResult == "Perpendicular")
                {
                    if (DrawWallArrows(_calculateVector(axisVector, ucs, true), ucs, true) == PromptStatus.OK)
                    {
                        ppr = Tools.GetAcadEditor().GetPoint(ppo);
                    }
                }
            }
            if (ppr.Status != PromptStatus.OK)
            {
                return(null);
            }
            return(ppr.Value);
        }
示例#30
0
        private Point3dCollection GetPointsFromUser()
        {
            var vertices = new Point3dCollection();
            // Set up the selection options
            // (used for all vertices)
            var verticesOpts = new PromptPointOptions("\nSelect point: ");

            verticesOpts.AllowNone = true;

            // Get the start point for the polyline
            var verticesRslt = _ed.GetPoint(verticesOpts);

            while (verticesRslt.Status == PromptStatus.OK)
            {
                // Add the selected point to the list
                vertices.Add(verticesRslt.Value);

                // Drag a temp line during selection of subsequent points
                verticesOpts.UseBasePoint  = true;
                verticesOpts.BasePoint     = verticesRslt.Value;
                verticesOpts.UseDashedLine = true;
                verticesRslt = _ed.GetPoint(verticesOpts);
                if (verticesRslt.Status == PromptStatus.OK)
                {
                    // For each point selected, draw a temporary segment
                    // start point, end point, current color, highlighted?
                    _ed.DrawVector(vertices[vertices.Count - 1], verticesRslt.Value, Color.FromColor(System.Drawing.Color.Yellow).ColorIndex, false);
                }
            }
            return(vertices);
        }
示例#31
0
        static public void DoIt()
        {
            Editor             ed   = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions opts = new PromptPointOptions("\nEnter Ellipse Center Point:");
            PromptPointResult  res  = ed.GetPoint(opts);

            Vector3d x         = Application.DocumentManager.MdiActiveDocument.Database.Ucsxdir;
            Vector3d y         = Application.DocumentManager.MdiActiveDocument.Database.Ucsydir;
            Vector3d NormalVec = x.CrossProduct(y);


            Database db = Application.DocumentManager.MdiActiveDocument.Database;

            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;

            //Create Ellipsejig
            EllipseJig jig = new EllipseJig(res.Value, NormalVec.GetNormal());

            //first call drag to get the major axis
            jig.setPromptCounter(0);
            Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig);
            // Again call drag to get minor axis
            jig.setPromptCounter(1);
            Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig);

            //Append entity.
            using (Transaction myT = tm.StartTransaction())
            {
                BlockTable       bt  = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead, false);
                BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
                btr.AppendEntity(jig.GetEntity());
                tm.AddNewlyCreatedDBObject(jig.GetEntity(), true);
                myT.Commit();
            }
        }
示例#32
0
文件: Class1.cs 项目: guchanghai/Cut
        public static void PickPoint()
        {
            //��ȡEditor����
               Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                PromptPointOptions promptPtOp = new PromptPointOptions("ѡ��һ���㣺");
                //ָ���Ļ��㣬���ָ���˸õ㣬����ѡ���ʱ�����һ����Ƥ�ߡ�
                promptPtOp.BasePoint = new Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0);
                PromptPointResult resPt;
                resPt = ed.GetPoint(promptPtOp);
                if (resPt.Status == PromptStatus.OK)
                {

                    ed.WriteMessage("ѡ��ĵ�Ϊ��" + resPt.Value.ToString());
                }
        }
        public bool StartDraw(out bool status)
        {
            status = false;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;
            if (this.startPoint == null)
            {

                PromptPointOptions opt = new PromptPointOptions("\n 选择管道的初始点");
                PromptPointResult res = ed.GetPoint(opt);
                if(res.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                if (res.Status != PromptStatus.OK)
                {
                    return false;
                }
                this.startPoint = res.Value;
            }
            mline = new Mline();
            using(Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                mline.Style = mlineStyleDic.GetAt("MLINEJIG");
            }
            mline.Normal = Vector3d.ZAxis;
            mline.Scale = PipeLine.GetScale();
            mline.AppendSegment((Point3d)this.startPoint);
            mline.AppendSegment((Point3d)this.startPoint);
            PromptResult res2 = ed.Drag(this);
            if (res2.Status == PromptStatus.OK)
            {
                return true;
            }
            else if (res2.Status == PromptStatus.Cancel || res2.Status == PromptStatus.None)
            {
                if(res2.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                return false;
            }
            return true;
        }
示例#34
0
        public static void getPointsFromUser()
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            PromptPointResult pPtRes;
            PromptPointOptions pPtOpts = new PromptPointOptions("");

            pPtOpts.Message = "\nEnter the start point of the line: ";
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptStart = pPtRes.Value;

            if(pPtRes.Status == PromptStatus.Cancel) return;

            pPtOpts.Message = "\nEnter the end point of the line: ";
            pPtOpts.UseBasePoint = true;
            pPtOpts.BasePoint = ptStart;
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptEnd = pPtRes.Value;

            if(pPtRes.Status == PromptStatus.Cancel) return;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()){
                BlockTable acBlkTbl;
                BlockTableRecord acBlkTblRec;

                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;

                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                Line acLine = new Line(ptStart, ptEnd);
                acLine.SetDatabaseDefaults();

                acBlkTblRec.AppendEntity(acLine);
                acTrans.AddNewlyCreatedDBObject(acLine, true);

                acDoc.SendStringToExecute("._zoom _all ", true, false, false);

                acTrans.Commit();

            }
        }
        public void MyCommand()
        {
            Active.Editor.WriteMessage("\nThis will add a circle to the current space!");

            // Put your command code here
            PromptPointOptions ppo = new PromptPointOptions("Pick the centre of the circle");
            PromptPointResult ppr = Active.Editor.GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
                return;

            Point3d pt = ppr.Value;

            PromptDistanceOptions pdo = new PromptDistanceOptions("Pick radius") {
                UseBasePoint = true,
                BasePoint = pt,
                AllowArbitraryInput = true
            };

            PromptDoubleResult pdr = Active.Editor.GetDistance(pdo);

            if (pdr.Status != PromptStatus.OK)
                return;

            double dist = pdr.Value;

            using (Transaction tr = Active.Database.TransactionManager.StartTransaction())
            {
                Circle circle = new Circle(pt, Vector3d.ZAxis, dist);

                BlockTableRecord btr = (BlockTableRecord) tr.GetObject(Active.Database.CurrentSpaceId, OpenMode.ForWrite);

                btr.AppendEntity(circle);
                tr.AddNewlyCreatedDBObject(circle, true);

                tr.Commit();
            }
        }
示例#36
0
文件: Class1.cs 项目: guchanghai/Cut
        public void CreateBlkRef()
        {
            //��ȡ��IJ����
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions ptOps = new PromptPointOptions("ѡ���IJ����");
            PromptPointResult ptRes;
            ptRes = ed.GetPoint(ptOps);
            Point3d ptInsert;
            if (ptRes.Status == PromptStatus.OK)
            {
                ptInsert = ptRes.Value ;
            }
            else
            {
                ptInsert = new Point3d(0, 0, 0);
            }

            Database db = HostApplicationServices.WorkingDatabase;
            // ʹ�� "using"�ؼ���ָ������ı߽�
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //��ȡ����ģ�Ϳռ�
                BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForWrite));
                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                //����������
                BlockReference blkRef = new BlockReference(ptInsert,CreateBlkDef());// ָ�������������õĿ���¼
                blkRef.Rotation = 1.57;//ָ����ת�ǣ�������

                //�����´����Ŀ����õ�ģ�Ϳռ�
                btr.AppendEntity(blkRef);
                trans.AddNewlyCreatedDBObject(blkRef, true);    // ֪ͨ�����´����˶���

                trans.Commit(); //�ύ����
            }
        }
        //矩形绘制按钮
        public void drawRectBtn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //CommandManager.Register();
            if(!HeatSourceLayoutApp.CommandManager.RequireLock())
            {
                HeatSourceLayoutApp.CommandManager.AddCommand(CommandManager.ToolCommand.DrawBuildingRect);
                Application.DocumentManager.MdiActiveDocument.SendStringToExecute("\x1B", true, false, false);

                return;
            }
            else
            {
                changeBtnStyle(2);
            }
            Utility.SetOrthoMode(false);
            HeatSourceLayoutApp.solutionPanel.SelectOutLineLayer();
            using(DocumentLock docLock = Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                Database db = HostApplicationServices.WorkingDatabase;
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                while (true)
                {
                    PromptPointOptions optPoint = new PromptPointOptions
                        ("\n请指定矩形的一个角点");
                    PromptPointResult resPoint = ed.GetPoint(optPoint);
                    if(HeatSourceLayoutApp.CommandManager.Status())
                    {
                        HeatSourceLayoutApp.CommandManager.ReleaseLock();
                        HeatSourceLayoutApp.CommandManager.TriggerCommand();
                        return;
                    }
                    if (resPoint.Status != PromptStatus.OK)
                    {
                        HeatSourceLayoutApp.CommandManager.ReleaseLock();
                        return;
                    }
                    Point3d pt1 = resPoint.Value;

                    Polyline polyLine2 = new Polyline();
                    for (int i = 0; i < 4; i++)
                    {
                        polyLine2.AddVertexAt(i, new Point2d(0, 0), 0, 0, 0);
                    }
                    polyLine2.Closed = true;

                    polyLine2.Color = Color.FromRgb(255, 0, 0);

                    RecJig elRecJig = new RecJig(pt1, polyLine2);

                    PromptResult resJig = ed.Drag(elRecJig);
                    if (resJig.Status == PromptStatus.OK)
                    {
                        if (elRecJig.m_PolyLine2.Area >= 1e-10)
                        {
                            ObjectId objid = AppendEntity(elRecJig.m_PolyLine2);
                            Building b = new Building(true);
                            b.BaseObjectId = objid;
                            HeatSource.HeatSourceLayoutApp.buildings.Add(objid, b);
                            //b.AddBuildingNumber();
                            b.Save();
                        }
                    }
                }
            }
        }
        BorderPromptResult GetBorderPoints()
        {
            PromptPointOptions ppo = new PromptPointOptions("\n" + CP.FrameFirstPointQuery);
            ppo.Keywords.Add(CO.Process);
            ppo.Keywords.Add(CO.NewScale);
            ppo.Keywords.Add(CO.Undo);
            ppo.Keywords.Add(CO.Cancel);
            // Запрашиваем первую точку
            PromptPointResult res1 = ed.GetPoint(ppo);
            if (res1.Status== PromptStatus.OK)
            {
                Point3d p1 = res1.Value;
                // Запрашиваем вторую точку
                PromptCornerOptions pco = new PromptCornerOptions(CP.FrameOppositePointQuery, p1);
                pco.UseDashedLine = true;
                PromptPointResult res2 = ed.GetCorner(pco);
                if (res2.Status != PromptStatus.OK)
                    return new BorderPromptResult(PromptResultStatus.Cancelled);

                p1 = p1.TransformBy(ed.CurrentUserCoordinateSystem);
                Point3d p2 = res2.Value.TransformBy(ed.CurrentUserCoordinateSystem);
                return new BorderPromptResult(p1, p2);
            }
            else if (res1.Status == PromptStatus.Keyword)
            {
                return new BorderPromptResult(res1.StringResult);
            }

            return new BorderPromptResult();
        }
示例#39
0
        // ����ͼ��
        public void SetData( )
        {
            string stmplate = string.Empty;
            stmplate = GetRbCheck();
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
             DocumentLock docLock = doc.LockDocument();
            Editor ed = doc.Editor;

            string PathName = @"\\172.16.7.55\dt$\" + stmplate + ".dwg";
            ed.WriteMessage(PathName);
            try
            {
                using (Database dbsource = new Database(false, false))
                {
                    dbsource.ReadDwgFile(PathName, System.IO.FileShare.Read, true, null);

                    PromptPointOptions pmops = new PromptPointOptions("please select a point :");
                    PromptPointResult pmres;
                    pmres = ed.GetPoint(pmops);
                    Point3d insertPt = pmres.Value;
                    ed.WriteMessage(insertPt[0].ToString());
                    ObjectId blockId = ObjectId.Null;

                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        #region ����ѡ��ͼ�����ͣ���������Ϣ������ͼ���

                        //7�ֱ�׼��+5��ֻ����ͼ�źͰ汾=12
                        if (stmplate == "A4����" || stmplate == "A3����" || stmplate == "A2����" || stmplate == "A1����" || stmplate == "A0����" || stmplate == "�޸�֪ͨ��" || stmplate == "�޸�֪ͨ��(�Ӽ�)" || stmplate == "A4���ݱ����" || stmplate == "A3���ݱ����" || stmplate == "A2���ݱ����" || stmplate == "A1���ݱ����" || stmplate == "A0���ݱ����")
                        {

                            blockId = db.Insert("tk", dbsource, false);
                            BlockTableRecord btupdate = (BlockTableRecord)tr.GetObject(blockId, OpenMode.ForWrite);
                            foreach (ObjectId otmp in btupdate)
                            {
                                DBObject dbo = tr.GetObject(otmp, OpenMode.ForWrite);
                                if (dbo is Autodesk.AutoCAD.DatabaseServices.DBText)
                                {

                                    DBText mText = (DBText)dbo;
                                    switch (mText.TextString)
                                    {
                                        case "Input Project Name Here":
                                            mText.TextString = lblpfullname.Text;
                                            break;

                                        case "Input Owner Here":
                                            mText.TextString = lblowner.Text;
                                            break;
                                        case "YRO***-***-***":
                                            mText.TextString = txtDrawNo.Text;
                                            break;
                                        case "0":
                                            mText.TextString = txtRev.Text;
                                            break;

                                    }

                                }
                                else if (dbo is Autodesk.AutoCAD.DatabaseServices.MText)
                                {
                                    MText mText = (MText)dbo;

                                    switch (mText.Contents)
                                    {
                                        case "ͼֽ����":

                                            mText.Contents = lblname1.Text;
                                            break;
                                        case "Input Title Here":
                                            mText.Contents = lblname2.Text;
                                            break;
                                        case "Input Class Here":
                                            mText.Contents = lblclass.Text;
                                            break;
                                    }
                                }
                            }

                            if (stmplate == "A4����" || stmplate == "A3����" || stmplate == "A2����" || stmplate == "A1����" || stmplate == "A0����" || stmplate == "�޸�֪ͨ��" || stmplate == "�޸�֪ͨ��(�Ӽ�)")
                            {
                                double qtnum = 0.0; ;

                                if (stmplate == "A4����" || stmplate == "�޸�֪ͨ��(�Ӽ�)" || stmplate == "�޸�֪ͨ��")
                                    qtnum = 63.3;
                                else if (stmplate == "A2����" || stmplate == "A1����" || stmplate == "A0����")
                                    qtnum = 68.5;
                                else
                                    qtnum = 66.3;

                                Point3d insertionPointnums = new Point3d(0, 0, 0);
                                DBText txt = new DBText();
                                try
                                {
                                    if (yt != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5, 0);
                                        txt = new DBText();
                                        txt.TextString = yt;
                                        txt.Position = insertionPointnums;

                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (hy != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 2, 0);
                                        txt = new DBText();
                                        txt.TextString = hy;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (lk != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 3, 0);
                                        txt.TextString = lk;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (om != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 4, 0);
                                        txt.TextString = om;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (qc != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 5, 0);
                                        txt = new DBText();
                                        txt.TextString = qc;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (xm != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 6, 0);
                                        txt = new DBText();
                                        txt.TextString = xm;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (pc != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 7, 0);
                                        txt.TextString = om;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }
                                    if (total != "")
                                    {
                                        insertionPointnums = new Point3d(19, qtnum - 4.5 * 9, 0);
                                        txt = new DBText();
                                        txt.TextString = total;
                                        txt.Position = insertionPointnums;
                                        btupdate.AppendEntity(txt);
                                        tr.AddNewlyCreatedDBObject(txt, true);
                                    }

                                }
                                catch (Autodesk.AutoCAD.Runtime.Exception re)
                                {
                                    MessageBox.Show(re.Message);
                                }

                            }

                        }

                        //else if (stmplate == "��·СƱ�����" || stmplate == "�޸�֪ͨ��A4�����" || stmplate == "�޸�֪ͨ��A3�����") { }

                        BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        BlockReference bref = new BlockReference(insertPt, blockId);

                        btr.AppendEntity(bref);
                        tr.AddNewlyCreatedDBObject(bref, true);
                        tr.Commit();

                        // bref.ExplodeToOwnerSpace();

                        #endregion
                    }
                }

                #region �����ӡ��¼
                string sp = string.Empty;
                sp = cmbproject.Text + ";" + txtDrawNo.Text + ";" + txtRev.Text + ";" + yt + ";" + hy + ";" + lk + ";" + om + ";" + qc + ";" + xm + ";" + pc + ";" + total;
                if (pi.GetDrawingPrintAddQuota(sp) != "0")
                    MessageBox.Show("�Ѳ���ͼ��ģ�壬������˴�ͼ�ŵĴ�ӡ����");
                #endregion
            }

            catch (System.Exception et)
            {
                MessageBox.Show(et.Message);
            }
            finally
            {
                docLock.Dispose();

                this.Show();
            }
        }
示例#40
0
        public void testpara(ListView mylist)
        {
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            DocumentLock loc = acDoc.LockDocument();
            Polyline test = new Polyline();

            using (loc)
            {
                Database acCurDb = acDoc.Database;
                PromptPointOptions pPtOpts = new PromptPointOptions(" 점을 입력하세요");
                PromptPointResult pPtRes = acDoc.Editor.GetPoint(pPtOpts);// PromptPointResult pPtRes = acDoc.Editor.GetPoint(pPtOpts); // 점을 사용자에게 가져온다
                Point2dCollection ptStart = new Point2dCollection(); // Point3d 의 배열형이라 생각하면 쉽다.

                pPtOpts.BasePoint = pPtRes.Value; // 기준점 (점선)
                pPtOpts.UseBasePoint = true;

                //pPtOpts.UseDashedLine = true;
                int count = 0; // 점갯수 count

                ptStart.Add(new Point2d(pPtRes.Value.X, pPtRes.Value.Y));

                while (pPtRes.Status == PromptStatus.OK) // 사용자한테 받는값이 있을때까지
                {
                    if (pPtRes.Status == PromptStatus.Cancel) { return; } // 캔슬시 리턴
                    pPtOpts.BasePoint = pPtRes.Value;
                    pPtOpts.Message = " 점을 입력하세요"; // ㅇㅇ
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);  // 사용자에게 점값을 받아온다

                    ptStart.Add(new Point2d(pPtRes.Value.X, pPtRes.Value.Y)); // 그값을 콜렉션에다가 배열로 저장
                    count++;

                }

                test.SetDatabaseDefaults(); // 폴리라인 초기화(버튼 두번누르면 초기화 안되므로)

                for (int i = 0; i < count; i++)
                {
                    test.AddVertexAt(i, ptStart[i], 0, 0, 0);
                }

                //          test.Closed = true; // 폴리라인을 폐합선으로 만들어줌 (도형)
                //

                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) // 트랜잭션으로 묵어줌 라인그리기 위해서
                {
                    BlockTable acBlkTbl;
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                 OpenMode.ForRead) as BlockTable;

                    BlockTableRecord acBlkTblRec;
                    acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                    OpenMode.ForWrite) as BlockTableRecord;

                    acBlkTblRec.AppendEntity(test); // 폴리라인을 블럭테이블 레코드에 그려준다.
                    acTrans.AddNewlyCreatedDBObject(test, true);//디비 데이터에 넣어줌
                    acTrans.Commit(); // 트랜잭션 실행
                }

            }
            Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen(); // 화면 한번 업뎃 해주고

            Alignment al = this.CreateAlign(test); // 만들어논 메소드를 이용해서 만들어진 평면선형 클래스의 변수값을 가져온다.

                int temp=0;

                temp = 0;
                foreach(AlignmentEntity myAe in al.Entities) //  일반 라인과 호의 순서가 맞진 않지만 정보는 다 맞음
                {                                                   ///추후에 정교한 작업 필요할듯
                    temp++;
                    string msg1 = "";
                    mylist.BeginUpdate();
                    ListViewItem testLvi2 = new ListViewItem(string.Format("{0}",temp));   // 리스트뷰 값 넣어주는 부분
                    switch(myAe.EntityType)
                    {
                        case AlignmentEntityType.Line:
                            AlignmentLine myLine = myAe as AlignmentLine;
                            msg1 = myLine.StartPoint.ToString(); // 시작점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.EndPoint.ToString(); // 끝점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.Length.ToString(); // 길이
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.StartStation.ToString(); // 시작 스테이션
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.EndStation.ToString(); // 끝 스테이션
                            testLvi2.SubItems.Add(msg1);

                            mylist.Items.Add(testLvi2);
                            break;
                        case AlignmentEntityType.Arc:
                            AlignmentArc myArc = myAe as AlignmentArc;
                            msg1 = myArc.StartPoint.ToString(); // 시작점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.EndPoint.ToString(); // 끝점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.Length.ToString(); // 길이
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.StartStation.ToString(); // 시작 스테이션
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.EndStation.ToString(); // 끝 스테이션
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.Radius.ToString(); // r 값
                            testLvi2.SubItems.Add(msg1);

                            mylist.Items.Add(testLvi2);
                            break;
                        default:
                            mylist.Items.Add("");
                            break;
                    }

                    mylist.EndUpdate(); // 포문안에 beginupdata 가 있으므로 마찬가지로 안쪽에 위치해줘야한다.
                }
        }
示例#41
0
        public void Create()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    //Prompts for each employee detail
                    PromptStringOptions prName = new PromptStringOptions("Enter Employee Name");
                    PromptStringOptions prDiv = new PromptStringOptions("Enter Employee Division");
                    PromptDoubleOptions prSal = new PromptDoubleOptions("Enter Employee Salary");
                    PromptPointOptions prPos = new PromptPointOptions("Enter Employee Position or");

                    //Add keywords when prompting for position
                    prPos.Keywords.Add("Name");
                    prPos.Keywords.Add("Division");
                    prPos.Keywords.Add("Salary");

                    //Set the default values for each of these
                    prName.DefaultValue = "Earnest Shackleton";
                    prDiv.DefaultValue = "Sales";
                    prSal.DefaultValue = 10000.0f;

                    //Set conditions for prompting
                    prPos.AllowNone = false; //Do not allow null values

                    //prompt results - set explicitly to null
                    PromptResult prNameRes = null;
                    PromptResult prDivRes = null;
                    PromptDoubleResult prSalRes = null;
                    PromptPointResult prPosRes = null;

                    //Loop to get employee details. Exit the loop when positon is entered
                    while (prPosRes == null || prPosRes.Status != PromptStatus.OK)
                    {
                        //Prompt for position
                        prPosRes = ed.GetPoint(prPos);
                        if (prPosRes.Status == PromptStatus.Keyword) //Got a keyword
                        {
                            switch (prPosRes.StringResult)
                            {
                                case "Name":
                                    //Get employee name
                                    prName.AllowSpaces = true;
                                    prNameRes = ed.GetString(prName);
                                    if (prNameRes.Status != PromptStatus.OK)
                                        throw new System.Exception("Error or User Cancelled");
                                    break;
                                case "Division":
                                    //Get employee division
                                    prDiv.AllowSpaces = true;
                                    prDivRes = ed.GetString(prDiv);
                                    if (prDivRes.Status != PromptStatus.OK)
                                        throw new System.Exception("Error or User Cancelled");
                                    break;
                                case "Salary":
                                    //Get employee salary
                                    prSal.AllowNegative = false;
                                    prSal.AllowNone = true;
                                    prSal.AllowZero = false;
                                    prSalRes = ed.GetDouble(prSal);
                                    if (prSalRes.Status != PromptStatus.OK & prSalRes.Status != PromptStatus.None)
                                        throw new System.Exception("Error or User Cancelled");
                                    break;
                            }
                        }
                        if (prPosRes.Status == PromptStatus.Cancel || prPosRes.Status == PromptStatus.Error)
                            throw new System.Exception("Error or User Cancelled");
                    }

                    //Create the Employee - either use the input value or the default value...
                    string empName = (prNameRes == null ? prName.DefaultValue : prNameRes.StringResult);
                    string divName = (prDivRes == null ? prDiv.DefaultValue : prDivRes.StringResult);
                    double salary = (prSalRes == null ? prSal.DefaultValue : prSalRes.Value);

                    CreateEmployee(empName, divName, salary, prPosRes.Value);

                    //Now create the division
                    //Pass an empty string for manager to check if it already exists
                    string manager = "";
                    ObjectId xRecId = CreateDivision(divName, manager);

                    //Open the department manager XRecord
                    Xrecord depMgrXRec = (Xrecord)trans.GetObject(xRecId, OpenMode.ForRead);
                    TypedValue[] typedVal = depMgrXRec.Data.AsArray();
                    foreach (TypedValue val in typedVal)
                    {
                        string str = (string)val.Value;
                        if (str == "")
                        {
                            //Manager was not set, now set it
                            // Prompt for  manager name first
                            ed.WriteMessage("\r\n");
                            PromptStringOptions prManagerName = new PromptStringOptions("No manager set for the division! Enter Manager Name");
                            prManagerName.DefaultValue = "Delton T. Cransley";
                            prManagerName.AllowSpaces = true;
                            PromptResult prManagerNameRes = ed.GetString(prManagerName);
                            if (prManagerNameRes.Status != PromptStatus.OK)
                                throw new System.Exception("Error or User Cancelled");
                            //Set a manager name
                            depMgrXRec.Data = new ResultBuffer(new TypedValue((int)DxfCode.Text, prManagerNameRes.StringResult));
                        }
                    }
                    trans.Commit();
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("\nError: " + ex.Message + "\n");
            }
        }
        public static void getPointsDelta()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();

            // Старт транзакции
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                PromptPointResult pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("");

                // Prompt for the start point
                pPtOpts.Message = "\nВведи точку перехода: ";
                pPtRes = acDoc.Editor.GetPoint(pPtOpts);

                int indX = Data.pathPoints.FindIndex(item => item == pPtRes.Value);

                //PromptStringOptions psoOpt = new PromptStringOptions("nВведите имя блока: ");
                PromptDoubleResult psoRes;
                PromptDoubleOptions psoOpt = new PromptDoubleOptions("");

                psoOpt.Message = "\nВведите длину перехода: ";
                psoRes = acDoc.Editor.GetDouble(psoOpt);
                Data.deltaPoints[indX] = psoRes.Value;

                // Сохранение нового объекта в базе данных
                acTrans.Commit();
            }
        }
示例#43
0
        public void PointTest()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions ptopts = new PromptPointOptions("Enter start point of the line");
            ptopts.BasePoint = new Point3d(1,1,1);
            ptopts.UseDashedLine = true;
            ptopts.Message = "Enter start point of the line";

            ed.PromptingForPoint += new PromptPointOptionsEventHandler(handle_promptPointOptions);
            ed.PromptedForPoint += new PromptPointResultEventHandler(handle_promptPointResult);
            PromptPointResult ptRes = ed.GetPoint(ptopts);
            ed.PromptingForPoint -= new PromptPointOptionsEventHandler(handle_promptPointOptions);
            ed.PromptedForPoint -= new PromptPointResultEventHandler(handle_promptPointResult);

            Point3d start = ptRes.Value;
            if(ptRes.Status == PromptStatus.Cancel)
            {
                ed.WriteMessage("Taking (0,0,0) as the start point");
            }

            ptopts.Message ="Enter end point of the line: ";
            ptRes = ed.GetPoint(ptopts);
            Point3d end = ptRes.Value;
            if(ptRes.Status == PromptStatus.Cancel)
            {
                ed.WriteMessage("Taking (0,0,0) as the end point");
            }

            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;

            using (Transaction myT = tm.StartTransaction())
            {
                BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId,OpenMode.ForRead,false);
                BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false);
                using (Line myline = new Line(start, end))
                {
                    btr.AppendEntity(myline);
                    tm.AddNewlyCreatedDBObject(myline, true);
                }
                myT.Commit();
            }
        }
示例#44
0
 private static void handle_promptPointOptions(object sender, PromptPointOptionsEventArgs e)
 {
     useThisPointOption = e.Options;
 }
示例#45
0
        /// <summary>
        ///  Функция getUserPoint запрашивает указание точки пользователем.
        /// </summary>
        /// <param name="msg">Сообщение выводимое на экран пользователю при запросе точки.</param>
        private static Point3d GetUserPoint(string msg)
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            //Editor acDocEd = acDoc.Editor;

            var promptPntOptns = new PromptPointOptions(msg) { AllowNone = false };

            PromptPointResult promptPntRes = acDoc.Editor.GetPoint(promptPntOptns);

            Point3d userPoint = promptPntRes.Value;

            if (promptPntRes.Status == PromptStatus.Cancel)
            {
                //acDocEd.WriteMessage("\nlog: getUserPoint: PromptStatus.CANCEL.");
                return new Point3d(2147483647, 2147483647, 2147483647);
            }
            //acDocEd.WriteMessage("\nlog: getUserPoint успешно выполнена. Возврат точки.");
            return userPoint;
        }
        //Рисуем таблицу щитка.
        private void b_paint_Click(object sender, EventArgs e)
        {
            this.Hide();
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (DocumentLock doclock = acDoc.LockDocument())
            {
                using (Transaction trans = acCurDb.TransactionManager.StartTransaction())
                {

                    PromptPointResult pPtRes;
                    PromptPointOptions pPtOpts = new PromptPointOptions("");
                    pPtOpts.Message = "\nВведи точку: ";
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                    // pPtRes.Value - точка типа Point3D
                    Data.table_x = pPtRes.Value.X;
                    Data.table_y = pPtRes.Value.Y;

                    BlockTableRecord btr;
                    BlockTable bt;
                    DBObjectCollection ObjColl = new DBObjectCollection();

                    //ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y, 0)));

                    //Вставили шапку таблицы.
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x + 285, Data.table_y, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 50, 0), new Point3d(Data.table_x + 285, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y - 15, 0), new Point3d(Data.table_x + 285, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 25, Data.table_y, 0), new Point3d(Data.table_x + 25, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 58, Data.table_y, 0), new Point3d(Data.table_x + 58, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 63, Data.table_y, 0), new Point3d(Data.table_x + 63, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 96, Data.table_y, 0), new Point3d(Data.table_x + 96, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y, 0), new Point3d(Data.table_x + 101, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 106, Data.table_y - 15, 0), new Point3d(Data.table_x + 106, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 123, Data.table_y - 15, 0), new Point3d(Data.table_x + 123, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 136, Data.table_y - 15, 0), new Point3d(Data.table_x + 136, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 161, Data.table_y - 15, 0), new Point3d(Data.table_x + 161, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 174, Data.table_y, 0), new Point3d(Data.table_x + 174, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 197, Data.table_y - 15, 0), new Point3d(Data.table_x + 197, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 210, Data.table_y, 0), new Point3d(Data.table_x + 210, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 226, Data.table_y - 15, 0), new Point3d(Data.table_x + 226, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 238, Data.table_y - 15, 0), new Point3d(Data.table_x + 238, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 250, Data.table_y - 15, 0), new Point3d(Data.table_x + 250, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 285, Data.table_y, 0), new Point3d(Data.table_x + 285, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 239, Data.table_y - 32, 0), new Point3d(Data.table_x + 249, Data.table_y - 32, 0)));

                    #region Текст в шапке
                    MText objText = new MText();
                    objText.SetDatabaseDefaults();
                    objText.Location = new Point3d(Data.table_x + 2, Data.table_y - 1, 0);
                    objText.Contents = "Распреде-\nлительное устройство";
                    objText.TextStyleId = acCurDb.Textstyle;
                    objText.TextHeight = 3;
                    objText.Height = 50;
                    objText.Width = 25;
                    ObjColl.Add(objText);

                    MText objText1 = new MText();
                    objText1.SetDatabaseDefaults();
                    objText1.TextStyleId = acCurDb.Textstyle;
                    objText1.TextHeight = 3;
                    objText1.Location = new Point3d(Data.table_x + 27, Data.table_y - 1, 0);
                    objText1.Contents = "Аппарат отходящей линии /ввода/, обозначение, тип, Iном, A, расцепитель или плавкая вставка, А.";
                    objText1.Height = 50;
                    objText1.Width = 31;
                    ObjColl.Add(objText1);

                    MText objText2 = new MText();
                    objText2.SetDatabaseDefaults();
                    objText2.TextStyleId = acCurDb.Textstyle;
                    objText2.TextHeight = 3;
                    objText2.Location = new Point3d(Data.table_x + 65, Data.table_y - 1, 0);
                    objText2.Contents = "Пусковой аппарат, обозначение, тип, Iном, A, расцепитель или плавкая вставка А, уставка теплового реле А.";
                    objText2.Height = 50;
                    objText2.Width = 31;
                    ObjColl.Add(objText2);

                    MText objText3 = new MText();
                    objText3.SetDatabaseDefaults();
                    objText3.TextStyleId = acCurDb.Textstyle;
                    objText3.TextHeight = 3;
                    objText3.Location = new Point3d(Data.table_x + 108, Data.table_y - 18, 0);
                    objText3.Contents = "Обозна-\nчение";
                    objText3.Height = 35;
                    objText3.Width = 17;
                    ObjColl.Add(objText3);

                    MText objText4 = new MText();
                    objText4.SetDatabaseDefaults();
                    objText4.TextStyleId = acCurDb.Textstyle;
                    objText4.TextHeight = 3;
                    objText4.Location = new Point3d(Data.table_x + 125, Data.table_y - 18, 0);
                    objText4.Contents = "Марка";
                    objText4.Height = 35;
                    objText4.Width = 13;
                    ObjColl.Add(objText4);

                    MText objText5 = new MText();
                    objText5.SetDatabaseDefaults();
                    objText5.TextStyleId = acCurDb.Textstyle;
                    objText5.TextHeight = 3;
                    objText5.Location = new Point3d(Data.table_x + 138, Data.table_y - 18, 0);
                    objText5.Contents = "Количество, число жил и сечение";
                    objText5.Height = 35;
                    objText5.Width = 25;
                    ObjColl.Add(objText5);

                    MText objText6 = new MText();
                    objText6.SetDatabaseDefaults();
                    objText6.TextStyleId = acCurDb.Textstyle;
                    objText6.TextHeight = 3;
                    objText6.Location = new Point3d(Data.table_x + 162, Data.table_y - 18, 0);
                    objText6.Contents = "Длина, м.";
                    objText6.Height = 35;
                    objText6.Width = 13;
                    ObjColl.Add(objText6);

                    MText objText7 = new MText();
                    objText7.SetDatabaseDefaults();
                    objText7.TextStyleId = acCurDb.Textstyle;
                    objText7.TextHeight = 3;
                    objText7.Location = new Point3d(Data.table_x + 175, Data.table_y - 18, 0);
                    objText7.Contents = "Обозначение на плане";
                    objText7.Height = 35;
                    objText7.Width = 23;
                    ObjColl.Add(objText7);

                    MText objText8 = new MText();
                    objText8.SetDatabaseDefaults();
                    objText8.TextStyleId = acCurDb.Textstyle;
                    objText8.TextHeight = 3;
                    objText8.Location = new Point3d(Data.table_x + 198, Data.table_y - 18, 0);
                    objText8.Contents = "Длина, м.";
                    objText8.Height = 35;
                    objText8.Width = 13;
                    ObjColl.Add(objText8);

                    MText objText9 = new MText();
                    objText9.SetDatabaseDefaults();
                    objText9.TextStyleId = acCurDb.Textstyle;
                    objText9.TextHeight = 3;
                    objText9.Location = new Point3d(Data.table_x + 212, Data.table_y - 18, 0);
                    objText9.Contents = "Обозна-\nчение";
                    objText9.Height = 35;
                    objText9.Width = 16;
                    ObjColl.Add(objText9);

                    MText objText10 = new MText();
                    objText10.SetDatabaseDefaults();
                    objText10.TextStyleId = acCurDb.Textstyle;
                    objText10.TextHeight = 3;
                    objText10.Location = new Point3d(Data.table_x + 227, Data.table_y - 18, 0);
                    objText10.Contents = "Pуст. или Pном., КВт";
                    objText10.Height = 35;
                    objText10.Width = 12;
                    ObjColl.Add(objText10);

                    MText objText11 = new MText();
                    objText11.SetDatabaseDefaults();
                    objText11.TextStyleId = acCurDb.Textstyle;
                    objText11.TextHeight = 3;
                    objText11.Location = new Point3d(Data.table_x + 239, Data.table_y - 18, 0);
                    objText11.Contents = "Iрасч. или Iном. Iпуск., А.";
                    objText11.Height = 35;
                    objText11.Width = 12;
                    ObjColl.Add(objText11);

                    MText objText12 = new MText();
                    objText12.SetDatabaseDefaults();
                    objText12.TextStyleId = acCurDb.Textstyle;
                    objText12.TextHeight = 3;
                    objText12.Location = new Point3d(Data.table_x + 252, Data.table_y - 18, 0);
                    objText12.Contents = "Наименование, тип, обозначение чертежа, принципиальной схемы.";
                    objText12.Height = 35;
                    objText12.Width = 35;
                    ObjColl.Add(objText12);

                    DBText acText = new DBText();
                    acText.SetDatabaseDefaults();
                    acText.Position = new Point3d(Data.table_x + 62, Data.table_y - 48, 0);
                    acText.Height = 3;
                    acText.TextString = "Участок сети 1";
                    acText.Rotation = 1.570796; //Это 90 градусов в радианах.
                    ObjColl.Add(acText);

                    DBText acText1 = new DBText();
                    acText1.SetDatabaseDefaults();
                    acText1.Rotation = 1.570796;
                    acText1.Height = 3;
                    acText1.Position = new Point3d(Data.table_x + 100, Data.table_y - 48, 0);
                    acText1.TextString = "Участок сети 2";
                    ObjColl.Add(acText1);

                    DBText acText2 = new DBText();
                    acText2.SetDatabaseDefaults();
                    acText2.Rotation = 1.570796;
                    acText2.Height = 3;
                    acText2.Position = new Point3d(Data.table_x + 105, Data.table_y - 48, 0);
                    acText2.TextString = "Участок сети";
                    ObjColl.Add(acText2);

                    DBText acText3 = new DBText();
                    acText3.SetDatabaseDefaults();
                    acText3.Height = 3;
                    acText3.Position = new Point3d(Data.table_x + 123, Data.table_y - 8, 0);
                    acText3.TextString = "Кабель, провод";
                    ObjColl.Add(acText3);
                    //acText.WidthFactor = 0.5;

                    DBText acText4 = new DBText();
                    acText4.SetDatabaseDefaults();
                    acText4.Height = 3;
                    acText4.Position = new Point3d(Data.table_x + 185, Data.table_y - 8, 0);
                    acText4.TextString = "Труба";
                    ObjColl.Add(acText4);

                    DBText acText5 = new DBText();
                    acText5.SetDatabaseDefaults();
                    acText5.Height = 3;
                    acText5.Position = new Point3d(Data.table_x + 230, Data.table_y - 8, 0);
                    acText5.TextString = "Электроприемник";
                    ObjColl.Add(acText5);
                    #endregion

                    Data.table_y = Data.table_y - 30;
                    double table_xx = Data.table_x, table_yy = Data.table_y - 20;

                    #region Вставляем строки таблицы
                    for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)
                    {
                        Data.table_y = Data.table_y - 20;

                        if (dataGridView1.Rows[j].Cells["Ветвь"].Value.ToString() == "Главная линия")
                        {
                            Line l_gl = new Line(new Point3d(Data.table_x + 25, Data.table_y - 20, 0), new Point3d(Data.table_x + 210, Data.table_y - 20, 0));
                            l_gl.LineWeight = LineWeight.LineWeight050;
                            l_gl.ColorIndex = 4;
                            ObjColl.Add(l_gl);
                        }

                        if (dataGridView1.Rows[j].Cells["Ветвь"].Value.ToString() == "Ответвление")
                        {
                            Line l_gl = new Line(new Point3d(Data.table_x + 62, Data.table_y, 0), new Point3d(Data.table_x + 60, Data.table_y - 2, 0));
                            l_gl.LineWeight = LineWeight.LineWeight050;
                            l_gl.ColorIndex = 4;
                            ObjColl.Add(l_gl);

                            Line l_gl1 = new Line(new Point3d(Data.table_x + 60, Data.table_y - 2, 0), new Point3d(Data.table_x + 60, Data.table_y - 20, 0));
                            l_gl1.LineWeight = LineWeight.LineWeight050;
                            l_gl1.ColorIndex = 4;
                            ObjColl.Add(l_gl1);

                            Line l_gl2 = new Line(new Point3d(Data.table_x + 60, Data.table_y - 20, 0), new Point3d(Data.table_x + 210, Data.table_y - 20, 0));
                            l_gl2.LineWeight = LineWeight.LineWeight050;
                            l_gl2.ColorIndex = 4;
                            ObjColl.Add(l_gl2);
                        }

                        if (dataGridView1.Rows[j].Cells["Род тока"].Value.ToString() == "1")
                        {
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 51, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 49, Data.table_y - 22.5, 0)));
                        }

                        if (dataGridView1.Rows[j].Cells["Род тока"].Value.ToString() == "3")
                        {
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 51, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 49, Data.table_y - 22.5, 0)));
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 52, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 50, Data.table_y - 22.5, 0)));
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 50, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 48, Data.table_y - 22.5, 0)));
                        }

                        ObjColl.Add(new Line(new Point3d(Data.table_x + 25, Data.table_y, 0), new Point3d(Data.table_x + 25, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 58, Data.table_y, 0), new Point3d(Data.table_x + 58, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 63, Data.table_y, 0), new Point3d(Data.table_x + 63, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 96, Data.table_y, 0), new Point3d(Data.table_x + 96, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y, 0), new Point3d(Data.table_x + 101, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 106, Data.table_y, 0), new Point3d(Data.table_x + 106, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 123, Data.table_y, 0), new Point3d(Data.table_x + 123, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 136, Data.table_y, 0), new Point3d(Data.table_x + 136, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 161, Data.table_y, 0), new Point3d(Data.table_x + 161, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 174, Data.table_y, 0), new Point3d(Data.table_x + 174, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 197, Data.table_y, 0), new Point3d(Data.table_x + 197, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 210, Data.table_y, 0), new Point3d(Data.table_x + 210, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 226, Data.table_y, 0), new Point3d(Data.table_x + 226, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 238, Data.table_y, 0), new Point3d(Data.table_x + 238, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 250, Data.table_y, 0), new Point3d(Data.table_x + 250, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 285, Data.table_y, 0), new Point3d(Data.table_x + 285, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y - 10, 0), new Point3d(Data.table_x + 210, Data.table_y - 10, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 210, Data.table_y - 20, 0), new Point3d(Data.table_x + 285, Data.table_y - 20, 0)));

                        DBText acText6 = new DBText();
                        acText6.SetDatabaseDefaults();
                        acText6.Height = 3;
                        acText6.Position = new Point3d(Data.table_x + 27, Data.table_y - 14, 0);
                        acText6.TextString = dataGridView1.Rows[j].Cells["Аппарат"].Value.ToString();
                        ObjColl.Add(acText6);

                        DBText acText7 = new DBText();
                        acText7.SetDatabaseDefaults();
                        acText7.Height = 3;
                        acText7.Position = new Point3d(Data.table_x + 27, Data.table_y - 18, 0);
                        acText7.TextString = dataGridView1.Rows[j].Cells["Ток"].Value.ToString();
                        ObjColl.Add(acText7);

                        DBText acText8 = new DBText();
                        acText8.SetDatabaseDefaults();
                        acText8.Height = 3;
                        acText8.Position = new Point3d(Data.table_x + 60, Data.table_y - 18, 0);
                        acText8.TextString = dataGridView1.Rows[j].Cells["Фаза"].Value.ToString();
                        ObjColl.Add(acText8);

                        DBText acText9 = new DBText();
                        acText9.SetDatabaseDefaults();
                        acText9.Height = 3;
                        acText9.Position = new Point3d(Data.table_x + 65, Data.table_y - 18, 0);
                        acText9.TextString = dataGridView1.Rows[j].Cells["Пусковой аппарат 1"].Value.ToString();
                        ObjColl.Add(acText9);

                        DBText acText10 = new DBText();
                        acText10.SetDatabaseDefaults();
                        acText10.Height = 3;
                        acText10.Position = new Point3d(Data.table_x + 65, Data.table_y - 14, 0);
                        acText10.TextString = dataGridView1.Rows[j].Cells["Пусковой аппарат 2"].Value.ToString();
                        ObjColl.Add(acText10);

                        DBText acText11 = new DBText();
                        acText11.SetDatabaseDefaults();
                        acText11.Height = 3;
                        acText11.Position = new Point3d(Data.table_x + 65, Data.table_y - 10, 0);
                        acText11.TextString = dataGridView1.Rows[j].Cells["Пусковой аппарат 3"].Value.ToString();
                        ObjColl.Add(acText11);

                        DBText acText12 = new DBText();
                        acText12.SetDatabaseDefaults();
                        acText12.Height = 3;
                        acText12.Position = new Point3d(Data.table_x + 108, Data.table_y - 8, 0);
                        acText12.TextString = dataGridView1.Rows[j].Cells["Обозначение 1"].Value.ToString();
                        ObjColl.Add(acText12);

                        DBText acText13 = new DBText();
                        acText13.SetDatabaseDefaults();
                        acText13.Height = 3;
                        acText13.Position = new Point3d(Data.table_x + 125, Data.table_y - 8, 0);
                        acText13.TextString = dataGridView1.Rows[j].Cells["Марка 1"].Value.ToString();
                        ObjColl.Add(acText13);

                        DBText acText14 = new DBText();
                        acText14.SetDatabaseDefaults();
                        acText14.Height = 3;
                        acText14.Position = new Point3d(Data.table_x + 138, Data.table_y - 8, 0);
                        acText14.TextString = dataGridView1.Rows[j].Cells["Жилы 1"].Value.ToString() + "x" + dataGridView1.Rows[j].Cells["Сечение 1"].Value.ToString();
                        ObjColl.Add(acText14);

                        DBText acText15 = new DBText();
                        acText15.SetDatabaseDefaults();
                        acText15.Height = 3;
                        acText15.Position = new Point3d(Data.table_x + 163, Data.table_y - 8, 0);
                        acText15.TextString = dataGridView1.Rows[j].Cells["Длина 1"].Value.ToString();
                        ObjColl.Add(acText15);

                        DBText acText16 = new DBText();
                        acText16.SetDatabaseDefaults();
                        acText16.Height = 3;
                        acText16.Position = new Point3d(Data.table_x + 108, Data.table_y - 18, 0);
                        acText16.TextString = dataGridView1.Rows[j].Cells["Обозначение 2"].Value.ToString();
                        ObjColl.Add(acText16);

                        DBText acText17 = new DBText();
                        acText17.SetDatabaseDefaults();
                        acText17.Height = 3;
                        acText17.Position = new Point3d(Data.table_x + 125, Data.table_y - 18, 0);
                        acText17.TextString = dataGridView1.Rows[j].Cells["Марка 2"].Value.ToString();
                        ObjColl.Add(acText17);

                        DBText acText18 = new DBText();
                        acText18.SetDatabaseDefaults();
                        acText18.Height = 3;
                        acText18.Position = new Point3d(Data.table_x + 138, Data.table_y - 18, 0);
                        if (dataGridView1.Rows[j].Cells["Жилы 2"].Value.ToString() + "x" + dataGridView1.Rows[j].Cells["Сечение 2"].Value.ToString() != "x")
                            acText18.TextString = dataGridView1.Rows[j].Cells["Жилы 2"].Value.ToString() + "x" + dataGridView1.Rows[j].Cells["Сечение 2"].Value.ToString();
                        else
                            acText18.TextString = "";
                        ObjColl.Add(acText18);

                        DBText acText19 = new DBText();
                        acText19.SetDatabaseDefaults();
                        acText19.Height = 3;
                        acText19.Position = new Point3d(Data.table_x + 163, Data.table_y - 18, 0);
                        acText19.TextString = dataGridView1.Rows[j].Cells["Длина 2"].Value.ToString();
                        ObjColl.Add(acText19);

                        DBText acText20 = new DBText();
                        acText20.SetDatabaseDefaults();
                        acText20.Height = 3;
                        acText20.Position = new Point3d(Data.table_x + 212, Data.table_y - 12, 0);
                        acText20.TextString = dataGridView1.Rows[j].Cells["Обознач. прием."].Value.ToString();
                        ObjColl.Add(acText20);

                        DBText acText21 = new DBText();
                        acText21.SetDatabaseDefaults();
                        acText21.Height = 3;
                        acText21.Position = new Point3d(Data.table_x + 228, Data.table_y - 12, 0);
                        acText21.TextString = dataGridView1.Rows[j].Cells["P"].Value.ToString();
                        ObjColl.Add(acText21);

                        DBText acText22 = new DBText();
                        acText22.SetDatabaseDefaults();
                        acText22.Height = 3;
                        acText22.Position = new Point3d(Data.table_x + 240, Data.table_y - 12, 0);
                        acText22.TextString = dataGridView1.Rows[j].Cells["I"].Value.ToString();
                        ObjColl.Add(acText22);

                        DBText acText23 = new DBText();
                        acText23.SetDatabaseDefaults();
                        acText23.Height = 3;
                        acText23.Position = new Point3d(Data.table_x + 252, Data.table_y - 12, 0);
                        acText23.TextString = dataGridView1.Rows[j].Cells["Наим. прием."].Value.ToString();
                        ObjColl.Add(acText23);

                        DBText acText24 = new DBText();
                        acText24.SetDatabaseDefaults();
                        acText24.Height = 3;
                        acText24.Position = new Point3d(Data.table_x + 103, Data.table_y - 8, 0);
                        acText24.TextString = "1";
                        ObjColl.Add(acText24);

                        DBText acText25 = new DBText();
                        acText25.SetDatabaseDefaults();
                        acText25.Height = 3;
                        acText25.Position = new Point3d(Data.table_x + 103, Data.table_y - 18, 0);
                        acText25.TextString = "2";
                        ObjColl.Add(acText25);
                    }
                    #endregion

                    Line l_ver = new Line(new Point3d(table_xx + 25, table_yy - 20, 0), new Point3d(table_xx + 25, Data.table_y - 26.5, 0));
                    l_ver.LineWeight = LineWeight.LineWeight050;
                    l_ver.ColorIndex = 4;
                    ObjColl.Add(l_ver);

                    Line l_ver1 = new Line(new Point3d(Data.table_x + 22.5, Data.table_y - 26.5, 0), new Point3d(Data.table_x + 27.5, Data.table_y - 26.5, 0));
                    l_ver1.LineWeight = LineWeight.LineWeight100;
                    l_ver1.ColorIndex = 4;
                    ObjColl.Add(l_ver1);

                    ObjColl.Add(new Line(new Point3d(Data.table_x, table_yy, 0), new Point3d(Data.table_x, Data.table_y - 20, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 20, 0), new Point3d(Data.table_x + 63, Data.table_y - 20, 0)));

                    Database wbd = HostApplicationServices.WorkingDatabase;

                    bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
                    btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                    foreach (Entity ent in ObjColl)
                    {
                        btr.AppendEntity(ent);
                        trans.AddNewlyCreatedDBObject(ent, true);
                    }
                    trans.Commit();
                    trans.Dispose();
                }
            }
            this.Show();
        }
示例#47
0
        private Point3d? TryGetPoint(string message, Point3d? basePoint)
        {
            PromptPointOptions options = new PromptPointOptions(message);
            if (basePoint.HasValue)
            {
                options.BasePoint = barPoint1.Value;
                options.UseBasePoint = true;
            }

            PromptPointResult resultPrompt = editor.GetPoint(options);
            if (resultPrompt.Status == PromptStatus.OK)
            {
                return resultPrompt.Value;
            }
            else
            {
                return null;
            }
        }
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     Document myDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
     DocumentLock myLock = myDoc.LockDocument();
     Database acCurDb = myDoc.Database;
     PromptPointResult pPtRes;
     PromptPointOptions pPtOpts = new PromptPointOptions("");
     pPtOpts.Message = "\nВведите точку: ";
     pPtRes = myDoc.Editor.GetPoint(pPtOpts);
     DrawBorders(pPtRes.Value);
 }
示例#49
0
        // Get distance between two user selected points.
        public Double GetDistance()
        {
            Double dist = 0;

            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            //Prompt for user selection of points to calculate distance.
            PromptPointResult ppr;
            Point2dCollection colPt = new Point2dCollection();
            PromptPointOptions ppo = new PromptPointOptions("");

            //Prompt for first point
            ppo.Message = "\nSpecify mid of Leftmost Rack: ";
            ppr = ed.GetPoint(ppo);
            colPt.Add(new Point2d(ppr.Value.X, ppr.Value.Y));

            //Exit if the user presses ESC or cancels cmd
            if (ppr.Status == PromptStatus.Cancel) return 0;

            int count = 1;

            while (count <= 2)
            {
                //Prompt for next points
                switch (count)
                {
                    case 1:
                        ppo.Message = "\nSpecify mid of Center Rack: ";
                        break;
                    case 2:
                        ppo.Message = "\nSpecify mid of Rightmost Rack: ";
                        break;
                }
                //use the previous point as the base point
                ppo.UseBasePoint = true;
                ppo.BasePoint = ppr.Value;

                ppr = ed.GetPoint(ppo);
                colPt.Add(new Point2d(ppr.Value.X, ppr.Value.Y));

                if (ppr.Status == PromptStatus.Cancel) return 0;

                //Increment
                count = count + 1;
            }

            //Create the polyline
            using (Polyline acPoly = new Polyline())
            {
                acPoly.AddVertexAt(0, colPt[0], 0, 0, 0);
                acPoly.AddVertexAt(1, colPt[1], 0, 0, 0);
                acPoly.AddVertexAt(2, colPt[2], 0, 0, 0);

                //Don't close polyline
                acPoly.Closed = false;

                //Query the length
                dist = acPoly.Length;

            }//Dispose of polyline.

            return dist; //returns the value of the distance.
        }
        public static void getPointsFloor()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();

            // Старт транзакции
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                PromptPointResult pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("");

                // Prompt for the start point
                pPtOpts.Message = "\nВведи начало на одном этаже: ";
                pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                Data.floorPointsStart.Add(pPtRes.Value);

                if (!Data.pathPoints.Contains(pPtRes.Value))
                    Data.pathPoints.Add(pPtRes.Value);

                pPtOpts.Message = "\nВведи конец на другом этаже: ";
                pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                Data.floorPointsEnd.Add(pPtRes.Value);

                if (!Data.pathPoints.Contains(pPtRes.Value))
                    Data.pathPoints.Add(pPtRes.Value);

                //PromptStringOptions psoOpt = new PromptStringOptions("nВведите имя блока: ");
                PromptDoubleResult psoRes;
                PromptDoubleOptions psoOpt = new PromptDoubleOptions("");

                psoOpt.Message = "\nВведите длину перехода: ";

                psoRes = acDoc.Editor.GetDouble(psoOpt);
                Data.floorPointsDistance.Add(psoRes.Value);

                // Сохранение нового объекта в базе данных
                acTrans.Commit();
            }
        }
示例#51
0
        // 만들어진 폴리라인을 가지고 선형을 만들어주는 메소드 선형뿐만아니라 그리드 뷰까지 찍어줌
        public Alignment CreateAlign(Polyline guid)
        {
            Document dc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; // 현재 도큐먼트를 가져옴
            Database db = dc.Database; // 현재 데이터베이스를 가져옴

            CivilDocument doc = CivilApplication.ActiveDocument;
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            using (Transaction acTrans = db.TransactionManager.StartTransaction())
            {
                BlockTable acBlktbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; // 선을 그리기 위한 블럭테이블 생성
                BlockTableRecord acblkTblrec = acTrans.GetObject(acBlktbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // 어디 도면에 그릴지 선택

                PolylineOptions plops = new PolylineOptions(); // 폴리라인 옵션 지정

                plops.AddCurvesBetweenTangents = true;
                plops.EraseExistingEntities = true;
                plops.PlineId = guid.ObjectId;

                ObjectId testAlignmentID = Alignment.Create(doc, plops, "내가만든 선형", null, "0", "Proposed", "All Labels");

                Alignment oAlignment = acTrans.GetObject(testAlignmentID, OpenMode.ForRead) as Alignment;

                ObjectId layerId = oAlignment.LayerId;
                // get first surface in the document
                ObjectId surfaceId = doc.GetSurfaceIds()[0];
                // get first style in the document
                ObjectId styleId = doc.Styles.ProfileStyles[0];
                // get the first label set style in the document
                ObjectId labelSetId = doc.Styles.LabelSetStyles.ProfileLabelSetStyles[0];

                try
                {
                    ObjectId profileId = Profile.CreateFromSurface("My Profile", testAlignmentID, surfaceId, layerId, styleId, labelSetId);

                }
                catch (Autodesk.AutoCAD.Runtime.Exception e)
                {
                    ed.WriteMessage(e.Message);
                }

                PromptPointResult pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("종단뷰를 그릴 위치를 찍어주세요~");
                pPtRes = dc.Editor.GetPoint(pPtOpts);
                Point3d ptStart = pPtRes.Value;
                if (pPtRes.Status == PromptStatus.Cancel) return null;

                // ObjectId ProfileViewId = ProfileView.Create(alignID, ptStart);
                ObjectId pfrVBSStyleId = doc.Styles.ProfileViewBandSetStyles[8];

                ObjectId ProfileViewId2 = ProfileView.Create(doc, "My Profile", pfrVBSStyleId, testAlignmentID, ptStart);
                //doc, "My Profile View", pfrVBSStyleId, alignID, ptInsert
                acTrans.Commit();
                return oAlignment;
            }
        }
        public static void getYourPath()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();
            double delta = 0;
            int indStart, indEnd = 0;
            List<int> colorPath = new List<int>();
            List<int> path = new List<int>();

            using (DocumentLock doclock = acDoc.LockDocument())
            {

                // Старт транзакции
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    PromptPointResult pPtRes;
                    PromptPointOptions pPtOpts = new PromptPointOptions("");

                    PromptDoubleResult psoRes;
                    PromptDoubleOptions psoOpt = new PromptDoubleOptions("");

                    // Prompt for the start point
                    pPtOpts.Message = "\nВведи начало пути: ";
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                    indStart = Data.pathPoints.FindIndex(item => item == pPtRes.Value);

                    psoOpt.Message = "\nВведите длину спуска: ";
                    if (Data.descentPoints[indStart] == 0)
                        psoOpt.DefaultValue = Data.descent;
                    else
                        psoOpt.DefaultValue = Data.descentPoints[indStart];

                    psoRes = acDoc.Editor.GetDouble(psoOpt);
                    if (Data.descentPoints[indStart] == 0)
                    {
                        Data.descentPoints[indStart] = psoRes.Value;
                        Data.descent = psoRes.Value;
                    }
                    delta = delta + psoRes.Value;
                    path.Add(indStart);

                    while (true)
                    {
                        pPtOpts.Message = "\nВведи следующую точку пути: ";
                        pPtRes = acDoc.Editor.GetPoint(pPtOpts);

                        indEnd = Data.pathPoints.FindIndex(item => item == pPtRes.Value);
                        if (indEnd == -1) break;
                        path.Add(indEnd);

                        //Application.ShowAlertDialog("Тут все хорошо 1");

                        colorPath = Class4.setPath(Data.arrayFloidS, path, indStart, indEnd, Data.arrayFloidS[indStart, indEnd]);
                        //Application.ShowAlertDialog("Тут все хорошо 2");

                        Data.dlina = Data.arrayFloidD[indStart, indEnd] + delta;

                        indStart = indEnd;

                    }

                    psoOpt.Message = "\nВведите длину спуска: ";
                    if (Data.descentPoints[indStart] == 0)
                        psoOpt.DefaultValue = Data.descent;
                    else
                        psoOpt.DefaultValue = Data.descentPoints[indStart];

                    psoRes = acDoc.Editor.GetDouble(psoOpt);
                    if (Data.descentPoints[indStart] == 0)
                    {
                        Data.descentPoints[indStart] = psoRes.Value;
                        Data.descent = psoRes.Value;
                    }
                    delta = delta + psoRes.Value;
                    Data.dlina = Data.dlina + delta;

                    PromptSelectionResult acSSPrompt1 = acDoc.Editor.GetSelection();
                    // Если статус запроса равен OK, объекты выбраны
                    if (acSSPrompt1.Status == PromptStatus.OK)
                    {
                        SelectionSet acSSet1 = acSSPrompt1.Value;

                        for (int i = 0; i < colorPath.Count - 1; i++)
                        {
                            //Application.ShowAlertDialog("Путь: " + colorPath[i].ToString());
                            foreach (SelectedObject acSSObj in acSSet1)
                            {
                                // Проверка, нужно убедиться в правильности полученного объекта
                                if (acSSObj != null)
                                {
                                    // Открытие объекта для чтения
                                    Line acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite) as Line;
                                    //Application.ShowAlertDialog("Тут все хорошо 3");
                                    if (acEnt != null)
                                    {
                                        int indS = Data.pathPoints.FindIndex(item => item == acEnt.StartPoint);
                                        int indE = Data.pathPoints.FindIndex(item => item == acEnt.EndPoint);
                                        if (((colorPath[i] == indS) && ((colorPath[i + 1] == indE))) || ((colorPath[i + 1] == indS) && ((colorPath[i] == indE))))
                                        {
                                            acEnt.ColorIndex = 3;
                                            if (!Data.pathName[indS].Contains(DataCabel.t_oboznach1))
                                            {
                                                Data.pathName[indS].Add(DataCabel.t_oboznach1);
                                               // Application.ShowAlertDialog("Тут все хорошо 1" + indS.ToString() + " " + DataCabel.t_oboznach1);
                                            }
                                            if (!Data.pathName[indE].Contains(DataCabel.t_oboznach1))
                                            {
                                                Data.pathName[indE].Add(DataCabel.t_oboznach1);
                                               // Application.ShowAlertDialog("Тут все хорошо 2" + indE.ToString() + " " + DataCabel.t_oboznach1);
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                    //Application.ShowAlertDialog((Data.arrayFloidD[indStart, indEnd] + delta).ToString()); показывает длину

                    // Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(tvf);
                    // tvf.writeText(arrayFloidD[indStart, indEnd]);

                    // Очистка транзакции

                    // Сохранение нового объекта в базе данных
                    acTrans.Commit();
                }
            }
        }
示例#53
0
        /// <summary>
        /// Selects a node.
        /// </summary>
        /// <param name="selectedNode">[out] The selected node.</param>
        /// <param name="promptString">[in] The prompt string.</param>
        /// <param name="mapTopology">[in] Map topology object.</param>
        /// <returns> 
        /// Returns true if successful.
        /// </returns>
        private bool SelectNode(ref Node selectedNode, string promptString, TopologyModel mapTopology)
        {
            // Select the node
            Point3d selectedPoints = new Point3d(0.0,0.0,0.0);
            ObjectId objSelectedNode = new ObjectId();

            MapApplication app = HostMapApplicationServices.Application;
            Editor editor = app.GetDocument(app.ActiveProject).Editor;
            PromptPointOptions option = new PromptPointOptions(string.Concat(promptString, "\n"));
            option.AllowNone = true;
            PromptPointResult promptPtRes = editor.GetPoint(option);

            if (promptPtRes.Status == PromptStatus.OK)
            {
                selectedPoints = promptPtRes.Value;

                Point3d ac3dPoint = HelperFunctions.Ucs2Wcs(selectedPoints);

                double distance = 0.0;

                // Create the Node from the point selected
                try
                {
                    mapTopology.FindNode(ref selectedNode, ref distance, ac3dPoint);
                    return true;
                }
                catch (MapException e)
                {
                    Utility.AcadEditor.WriteMessage(string.Format("\nERROR: Unable to find node for read with error code: {0}.", e.ErrorCode));
                    return false;
                }
            }

            return false;
        }
示例#54
0
        public void DrawGroupLeader()
        {
            Editor ed = dwg.Editor;
            PromptEntityOptions prmtEntityOpts = new PromptEntityOptions("Укажите линию");
            prmtEntityOpts.AllowNone = false;
            prmtEntityOpts.SetRejectMessage("Должна быть линия или полилиния!");
            prmtEntityOpts.AddAllowedClass(typeof(Line), true);
            prmtEntityOpts.AddAllowedClass(typeof(Polyline), true);
            PromptEntityResult entRes = ed.GetEntity(prmtEntityOpts);
            if (entRes.Status!= PromptStatus.OK)
            {
                return;
            }
            using (Transaction tr = CurrentDatabase.TransactionManager.StartTransaction())
            {
                GroupsInformation groupEntities = new GroupsInformation(tr, CurrentDatabase);
                List<string> groupList = groupEntities.GetGroupsOfObject(entRes.ObjectId);
                if (groupList == null)
                {
                    ed.WriteMessage("За указанным объектом не значится никаких групп!");
                    return;
                }
                PromptPointOptions pointOpts = new PromptPointOptions("\nУкажите точку вставки блока: ");
                PromptPointResult pointRes = ed.GetPoint(pointOpts);
                if (pointRes.Status!= PromptStatus.OK)
                {
                    return;
                }
                BlockTable bt = (BlockTable)CurrentDatabase.BlockTableId.GetObject(OpenMode.ForRead);
                BlockTableRecord btrSpace = (BlockTableRecord)CurrentDatabase.CurrentSpaceId
                    .GetObject(OpenMode.ForWrite);
                if (!bt.Has("group_vinoska"))
                {
                    ed.WriteMessage("\nВ файле не определён блок выноски!!");
                    return;
                }
                BlockTableRecord gleaderBtr = (BlockTableRecord)bt["group_vinoska"].GetObject(OpenMode.ForRead);
                BlockReference gleader = new BlockReference(pointRes.Value, gleaderBtr.ObjectId);
                btrSpace.AppendEntity(gleader);
                tr.AddNewlyCreatedDBObject(gleader, true);

                //Если блок аннотативный - добавляем в таблицу аннотативных масштабов блока текущий масштаб
                ObjectContextManager ocm = CurrentDatabase.ObjectContextManager;
                ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
                if (gleaderBtr.Annotative == AnnotativeStates.True)
                {
                    ObjectContexts.AddContext(gleader, occ.CurrentContext);
                }

                gleader.SetDatabaseDefaults();
                if (gleaderBtr.HasAttributeDefinitions)
                {
                    var attDefs = gleaderBtr.Cast<ObjectId>()
                        .Where(n => n.ObjectClass.Name == "AcDbAttributeDefinition")
                        .Select(n => (AttributeDefinition)n.GetObject(OpenMode.ForRead));
                    foreach (AttributeDefinition attdef in attDefs)
                    {
                        AttributeReference attref = new AttributeReference();
                        attref.SetAttributeFromBlock(attdef, gleader.BlockTransform);
                        gleader.AttributeCollection.AppendAttribute(attref);
                        tr.AddNewlyCreatedDBObject(attref, true);
                        if (gleaderBtr.Annotative == AnnotativeStates.True)
                        {
                            ObjectContexts.AddContext(attref, occ.CurrentContext);
                        }
                        int attCount = int.Parse(attref.Tag.Remove(0,10));
                        if (attCount<=groupList.Count)
                        {
                            attref.TextString = groupList[attCount-1];
                        }
                    }
                }

                if (gleaderBtr.IsDynamicBlock)
                {
                    DynamicBlockReferencePropertyCollection dynBRefColl = gleader.DynamicBlockReferencePropertyCollection;
                    foreach (DynamicBlockReferenceProperty prop in dynBRefColl)
                    {
                        if (prop.PropertyName == "Lookup1")
                        {
                            prop.Value = prop.GetAllowedValues()[groupList.Count-1];
                        }
                    }
                }
                tr.Commit();
            }
        }
示例#55
0
 public static IAcedCmdArg Argument(PromptPointOptions options)
 {
     return new PromptPointArgument(options);
 }
        //生成block预览
        //插入block
        public void Insertblock(string s, out bool status)
        {
            status = false;
            DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
            Database db = HostApplicationServices.WorkingDatabase;
            ObjectId spaceId = db.CurrentSpaceId;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            String promptText = s.Contains("锅炉") ? "\n 选择插入热源的位置" : "\n 选择插入热力站的位置";
            PromptPointOptions getPointOptions = new PromptPointOptions(promptText);
            getPointOptions.AppendKeywordsToMessage = true;
            PromptPointResult getPointResult = ed.GetPoint(getPointOptions);

            if(getPointResult.Status == PromptStatus.Cancel)
            {
                status = true;
                return;
            }
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                ObjectId layerid = HeatSourceLayoutApp.currentSolution.BaseObjectId;
                LayerTableRecord layer = trans.GetObject(layerid, OpenMode.ForWrite) as LayerTableRecord;
                ObjectId blockid = spaceId.InsertBlockReference(layer.Name, s, getPointResult.Value, new Scale3d(HeatSourceLayoutApp.globalProperty.BlockScale), 0);
                trans.Commit();
                //将新建的热力站/热源存入解决方案的对象中
                if (s.CompareTo("锅炉5吨") == 0)
                {
                    HeatProducer producer = new HeatProducer(HeatSourceLayoutApp.currentSolution, true);
                    producer.BaseObjectId = blockid;
                    producer.Save();
                    HeatSourceLayoutApp.currentSolution.HeatProducers.Add(blockid, producer);
                }
                else if (s.CompareTo("换热机组") == 0)
                {
                        SubStation station = new SubStation(HeatSource.HeatSourceLayoutApp.currentSolution, true);
                        station.BaseObjectId = blockid;
                        station.Save();
                        HeatSourceLayoutApp.currentSolution.SubStations.Add(blockid, station);
                 }
            }
        }
示例#57
0
        public void SelectOt()  //"please select a point ,then get the coordinate :"
        {
            PromptPointOptions pmops = new PromptPointOptions("please select a point ,then get the coordinate :");
            
            PromptPointResult pmres;
            Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor;
            
            pmres = ed.GetPoint(pmops);

            if (pmres.Status != PromptStatus.OK)
                ed.WriteMessage("Error");
            else
            {
                ed.WriteMessage("You selected point " + pmres.Value.ToString());
            }

        }
        public void GetIntersectionsRiver()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Transaction tr = db.TransactionManager.StartTransaction();

            #region For Word
            string filepath = "D:\\intersections_rivers.docx";

            using (WordprocessingDocument docX = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document))
            {
                try
                {
                    // Add a main document part.
                    MainDocumentPart mainPart = docX.AddMainDocumentPart();
                    StyleDefinitionsPart styleDefinitionsPart = mainPart.AddNewPart<StyleDefinitionsPart>();
                    Styles styles1 = new Styles();
                    DocDefaults docDefaults =
                        new DocDefaults(
                            new RunPropertiesDefault(new RunPropertiesBaseStyle(new RunFonts()
                            {
                                Ascii = "Times New Roman",
                                HighAnsi = "Times New Roman",
                                ComplexScript = "Times New Roman"
                            }, new FontSize() { Val = "24" },
                                new FontSizeComplexScript() { Val = "24" })),
                                new ParagraphPropertiesDefault(new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto }));
                    styles1.AppendChild(docDefaults);
                    styleDefinitionsPart.Styles = styles1;

                    mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();
                    DocumentFormat.OpenXml.Wordprocessing.Body body = mainPart.Document.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Body());
                    ParagraphProperties paragraphProperties1 = new ParagraphProperties(
                        new Justification() { Val = JustificationValues.Center },
                        new ParagraphMarkRunProperties(
                            new RunFonts()
                            {
                                Ascii = "Times New Roman",
                                HighAnsi = "Times New Roman",
                                ComplexScript = "Times New Roman"
                            },
                            new FontSize() { Val = "24" },
                            new FontSizeComplexScript() { Val = "24" }
                            ));

                    Paragraph para = body.AppendChild(new Paragraph());
                    para.AppendChild(paragraphProperties1);

                    Run run = para.AppendChild(new Run());

                    RunProperties runProperties1 = new RunProperties(
                        new Bold());

                    // String msg contains the text, "Hello, Word!"
                    run.AppendChild(runProperties1);
                    run.AppendChild(new Text("ПРИЛОЖЕНИЕ"));
                    run.AppendChild(new Break());
                    run.AppendChild(new Text("Ведомость пересечений"));
                    run.AppendChild(new Break());

                    var table = new DocumentFormat.OpenXml.Wordprocessing.Table();
                    // Create a TableProperties object and specify its border information.
                    TableProperties tblProp = new TableProperties(
                        new TableWidth() { Width = "9782", Type = TableWidthUnitValues.Dxa },
                        new TableIndentation() { Width = -318, Type = TableWidthUnitValues.Dxa },
                        new TableBorders(
                            new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 }),
                        new DocumentFormat.OpenXml.Wordprocessing.TableStyle() { Val = "TableGrid" }
                        );

                    // Append the TableProperties object to the empty table.
                    table.AppendChild<TableProperties>(tblProp);

                    // Add 3 columns to the table.
                    TableGrid tg = new TableGrid(new GridColumn(), new GridColumn(), new GridColumn(), new GridColumn(),
                         new GridColumn(), new GridColumn(), new GridColumn(), new GridColumn(), new GridColumn());
                    table.AppendChild(tg);

                    TableRow tr1 = new TableRow(
                        new TableRowProperties(new TableRowHeight() { Val = 430 }),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1709" },
                                new VerticalMerge() { Val = MergedCellValues.Restart },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()),
                                new Run(new Text("Наимен. водотока")))),
                        //new TableCellProperties(new TableCellWidth() {Type = TableWidthUnitValues.Pct, Width = "500"})
                        new TableCell(
                            new TableCellProperties(
                                new GridSpan() { Val = 2 },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center },
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "3922" }),
                            new Paragraph(
                                new ParagraphProperties(new Justification() { Val = JustificationValues.Center }),
                                new Run(new Text("Пикетное положение пересечения")))),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(
                                new ParagraphProperties(new Justification() { Val = JustificationValues.Center }),
                                new Run(new Text("Ширина водотока в межень")))),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1358" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center },
                                new VerticalMerge() { Val = MergedCellValues.Restart }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()),
                                new Run(new Text("Глуб. водотока")))),
                        new TableCell(
                            new TableCellProperties(
                                new GridSpan() { Val = 3 },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center },
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2368" }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()),
                                new Run(new Text("Горизонт воды")))),
                        new TableCell(new TableCellProperties(
                            new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "425" },
                            new VerticalMerge() { Val = MergedCellValues.Restart },
                            new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("Прим."))))
                        );
                    table.AppendChild(tr1);
                    TableRow tr2 = new TableRow(
                        new TableRowProperties(new TableRowHeight() { Val = 419 }),
                        new TableCell(new TableCellProperties(new VerticalMerge()), new Paragraph(new Run())),
                        new TableCell(
                            new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new ParagraphProperties(new Justification() { Val = JustificationValues.Center }), new Paragraph(new Run(new Text("От")))),
                        new TableCell(
                            new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new ParagraphProperties(new Justification() { Val = JustificationValues.Center }), new Paragraph(new Run(new Text("До")))),
                        new TableCell(
                            new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new ParagraphProperties(new Justification() { Val = JustificationValues.Center }), new Paragraph(new Run(new Text("половодье")))),
                        new TableCell(new TableCellProperties(new VerticalMerge()), new Paragraph(new Run())),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1260" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("Дата съемки")))),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1108" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("На день съемки")))),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1108" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("Макс.")))),
                        new TableCell(new TableCellProperties(new VerticalMerge()), new Paragraph(new Run())));
                    table.AppendChild(tr2);

                    TableCellProperties tcp = new TableCellProperties(new GridSpan() { Val = 9 });
            #endregion

                    while (true)
                    {

                        //using (tr)
                        //{
                        try
                        {
                            #region Поиск пересечений
                            BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                            PromptEntityOptions peo = new PromptEntityOptions("\nВыбери polyline  >>");
                            peo.SetRejectMessage("\nМожно только polyline >>");
                            peo.AddAllowedClass(typeof(Polyline), false);
                            PromptEntityResult res;
                            res = ed.GetEntity(peo);
                            if (res.Status != PromptStatus.OK)
                            {
                                break;
                            }
                            DBObject ent = (DBObject)tr.GetObject(res.ObjectId, OpenMode.ForRead);
                            if (ent == null) return;

                            PromptPointResult pPtRes;
                            PromptPointOptions pPtOpts = new PromptPointOptions("");
                            // Prompt for the start point
                            pPtOpts.Message = "\nВведи начало: ";
                            pPtRes = doc.Editor.GetPoint(pPtOpts);

                            PromptDoubleOptions getpik = new PromptDoubleOptions("\nВведи пикетаж (в формате числа, а не 0+00): ");
                            PromptDoubleResult getpikRes = doc.Editor.GetDouble(getpik);

                            //zoom
                            /*PromptEntityResult per = ed.GetEntity(peo);

                            if (per.Status != PromptStatus.OK)
                                return;*/

                            // Extract its extents

                            Extents3d ext;

                            Transaction trans = db.TransactionManager.StartTransaction();
                            using (trans)
                            {
                                Entity enti = (Entity)trans.GetObject(res.ObjectId, OpenMode.ForRead);
                                ext = enti.GeometricExtents;
                                trans.Commit();
                            }

                            ext.TransformBy(ed.CurrentUserCoordinateSystem.Inverse());

                            ZoomWin(ed, ext.MinPoint, ext.MaxPoint);
                            //

                            //Polyline poly = (Polyline)ent as Polyline;
                            Curve curv = ent as Curve;

                            DBObjectCollection pcurves = new DBObjectCollection();

                            curv.Explode(pcurves);
                            TypedValue[] values = new TypedValue[]
                     {
                        new TypedValue(0, "lwpolyline")
                        //might be added layer name to select curve:
                        //, new TypedValue(8, "mylayer")
                     };
                            SelectionFilter filter = new SelectionFilter(values);

                            Point3dCollection fence = new Point3dCollection();

                            double leng = curv.GetDistanceAtParameter(curv.EndParam) - curv.GetDistanceAtParameter(curv.StartParam);
                            // number of divisions along polyline to create fence selection
                            double step = leng / 256;// set number of steps to your suit

                            int num = Convert.ToInt32(leng / step);

                            for (int i = 0; i < num; i++)
                            {
                                Point3d pp = curv.GetPointAtDist(step * i);

                                fence.Add(curv.GetClosestPointTo(pp, false));
                            }

                            PromptSelectionResult selres = ed.SelectFence(fence, filter);

                            if (selres.Status != PromptStatus.OK) return;
                            Point3dCollection intpts = new Point3dCollection();

                            DBObjectCollection qcurves = new DBObjectCollection();
                            //ed.WriteMessage("\nCheck");
                            foreach (SelectedObject selobj in selres.Value)
                            {
                                DBObject obj = tr.GetObject(selobj.ObjectId, OpenMode.ForRead, false) as DBObject;
                                if (selobj.ObjectId != curv.ObjectId)
                                {
                                    DBObjectCollection icurves = new DBObjectCollection();
                                    Curve icurv = obj as Curve;
                                    icurv.Explode(icurves);
                                    foreach (DBObject dbo in icurves)
                                    {
                                        if (!qcurves.Contains(dbo))
                                            qcurves.Add(dbo);
                                    }
                                }

                            }
                            //ed.WriteMessage("\n{0}", qcurves.Count);

                            int j = 0;
                            Point3dCollection polypts = new Point3dCollection();

                            for (int i = 0; i < pcurves.Count; ++i)
                            {
                                for (j = 0; j < qcurves.Count; ++j)
                                {
                                    Curve curve1 = pcurves[i] as Curve;

                                    Curve curve2 = qcurves[j] as Curve;

                                    Point3dCollection pts = new Point3dCollection();

                                    curve1.IntersectWith(curve2, Intersect.OnBothOperands, pts, IntPtr.Zero, IntPtr.Zero);

                                    foreach (Point3d pt in pts)
                                    {
                                        if (!polypts.Contains(pt))
                                            polypts.Add(pt);
                                    }
                                }
                            }
                            #endregion

                            try
                            {
                                using (Transaction tran = db.TransactionManager.StartTransaction())
                                {
                                    Polyline pline = (Polyline)tran.GetObject(res.ObjectId, OpenMode.ForRead);
                                    table.AppendChild(new TableRow(
                                        new TableCell(
                                            new TableCellProperties(
                                                new GridSpan() { Val = 9 }),
                                                new Paragraph(
                                                    new ParagraphProperties(
                                                        new ParagraphMarkRunProperties(new Bold()),
                                                        new Justification() { Val = JustificationValues.Center }),
                                                        new Run(new RunProperties(
                                                            new Bold()),
                                                            new Text("ПК" + ((int)(getpikRes.Value)).ToString("F0") + "-ПК" +
                                                                ((int)(100 * getpikRes.Value + pline.Length) / 100).ToString("F0") + "+" +
                                                                ((100 * getpikRes.Value + pline.Length) % 100).ToString("F")))))));
                                }
                            }
                            catch { ed.WriteMessage("\nError."); }

                            Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("osmode", 0);// optional
                            // for debug only
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("\nНайдено пересечений: {0}", polypts.Count));

                            if (polypts.Count == 0)
                            {
                                try
                                {
                                    using (Transaction tran = db.TransactionManager.StartTransaction())
                                    {
                                        Polyline pline = (Polyline)tran.GetObject(res.ObjectId, OpenMode.ForRead);
                                        table.AppendChild(new TableRow(
                                            new TableCell(
                                                new TableCellProperties(
                                                    new GridSpan() { Val = 9 }),
                                                    new Paragraph(
                                                        new ParagraphProperties(
                                                            new Justification() { Val = JustificationValues.Center }),
                                                            new Run(new Text("На данном участке трассы пересечения отсутствуют"))))));
                                    }
                                }
                                catch { ed.WriteMessage("\nError."); }
                            }
                            else
                            {
                                //List<double> pik = new List<double>(polypts.Count);
                                double[] pik = new double[polypts.Count];
                                int numInter = 0;

                                foreach (Point3d inspt in polypts)
                                {
                                    double dist = 0;
                                    dist = 100 * getpikRes.Value;

                                    // test for visulization only
                                    /*Circle circ = new Circle(inspt, Vector3d.ZAxis, 10 * db.Dimtxt);
                                    circ.ColorIndex = 1;
                                    btr.AppendEntity(circ);
                                    tr.AddNewlyCreatedDBObject(circ, true);*/

                                    Point3d curr = pPtRes.Value, next = pPtRes.Value;
                                    try
                                    {
                                        using (Transaction tran = db.TransactionManager.StartTransaction())
                                        {
                                            Polyline pline = (Polyline)tran.GetObject(res.ObjectId, OpenMode.ForRead);
                                            if ((pPtRes.Value == pline.GetLineSegmentAt(0).StartPoint) || (pPtRes.Value == pline.GetLineSegmentAt(0).EndPoint))
                                                for (int i = 0; i < pline.NumberOfVertices - 2; i++)
                                                {
                                                    LineSegment3d l1 = pline.GetLineSegmentAt(i);
                                                    LineSegment3d l2 = pline.GetLineSegmentAt(i + 1);
                                                    double angle = GetPolylineShape(l1, l2, pline.Normal);
                                                    if (angle > Math.PI)
                                                    {
                                                        if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                                            next = l1.StartPoint;
                                                        else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                                            next = l1.EndPoint;
                                                    }
                                                    else
                                                    {
                                                        if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                                            next = l1.StartPoint;
                                                        else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                                            next = l1.EndPoint;
                                                    }

                                                    if (Math.Abs(inspt.DistanceTo(curr) + inspt.DistanceTo(next) - curr.DistanceTo(next)) < 1)
                                                    {
                                                        dist += inspt.DistanceTo(curr);
                                                        ed.WriteMessage(((int)dist / 100).ToString("F0") + "+" + (dist % 100).ToString("F") + "\n");
                                                        break;
                                                    }
                                                    else
                                                        dist += curr.DistanceTo(next);

                                                    curr = next;
                                                }
                                            else
                                                for (int i = pline.NumberOfVertices - 3; i >= 0; i--)
                                                {
                                                    LineSegment3d l1 = pline.GetLineSegmentAt(i);
                                                    LineSegment3d l2 = pline.GetLineSegmentAt(i + 1);
                                                    double angle = GetPolylineShape(l1, l2, pline.Normal);
                                                    if (angle > Math.PI)
                                                    {
                                                        if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                                            next = l1.StartPoint;
                                                        else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                                            next = l1.EndPoint;
                                                    }
                                                    else
                                                    {
                                                        if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                                            next = l1.StartPoint;
                                                        else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                                            next = l1.EndPoint;
                                                    }

                                                    if (Math.Abs(inspt.DistanceTo(curr) + inspt.DistanceTo(next) - curr.DistanceTo(next)) < 1)
                                                    {
                                                        dist += inspt.DistanceTo(curr);
                                                        ed.WriteMessage(((int)dist / 100).ToString("F0") + "+" + (dist % 100).ToString("F") + "\n");
                                                        break;
                                                    }
                                                    else
                                                        dist += curr.DistanceTo(next);

                                                    curr = next;
                                                }
                                        }
                                    }
                                    catch
                                    {
                                        ed.WriteMessage("\nInvalid polyline.");
                                    }
                                    pik[numInter] = dist;
                                    numInter++;
                                    //ed.WriteMessage(" {0:0.00}\n", dist);
                                }

                                //pik.Sort();

                                Array.Sort(pik);

                                for (int i = 0; i < polypts.Count; i++)
                                {
                                    tr1 = new TableRow(
                                        new TableRowProperties(new TableRowHeight() { Val = 300 }),
                                        new TableCell(new Paragraph(new Run())),
                                        new TableCell(
                                                new TableCellProperties(
                                                    new GridSpan() { Val = 2 }),
                                                    new Paragraph(
                                                        new ParagraphProperties(
                                                            new Justification() { Val = JustificationValues.Center }),
                                                            new Run(new Text(((int)pik[i] / 100).ToString("F0") + "+" + (pik[i] % 100).ToString("F"))))),
                                        new TableCell(new Paragraph(new Run())),
                                        new TableCell(new Paragraph(new Run())),
                                        new TableCell(new Paragraph(new Run())),
                                        new TableCell(new Paragraph(new Run())),
                                        new TableCell(new Paragraph(new Run())),
                                        new TableCell(new Paragraph(new Run()))
                                        );
                                    table.AppendChild(tr1);
                                }
                            }

                        }
                        catch
                        {
                            ed.WriteMessage("\nError");
                        }
                        //}
                    }

                    tr.Commit();

                    body.AppendChild(table);
                    body.AppendChild(
                        new SectionProperties(
                            new PageMargin()
                            {
                                Top = 1134,
                                Right = (UInt32Value)850U,
                                Bottom = 1134,
                                Left = (UInt32Value)1418U,
                                Header = (UInt32Value)708U,
                                Footer = (UInt32Value)708U,
                                Gutter = (UInt32Value)0U
                            }));
                    ed.WriteMessage("\nДокумент сохранен в D:\\intersections_rivers.docx");
                }
                catch
                {
                    ed.WriteMessage("\nError.");
                }
            }
        }
        public void getang()
        {
            Autodesk.AutoCAD.ApplicationServices.Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            string filepath = "D:\\tdoc.docx";

            using (WordprocessingDocument docX = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document))
            {
                try
                {
                    // Add a main document part.
                    MainDocumentPart mainPart = docX.AddMainDocumentPart();
                    StyleDefinitionsPart styleDefinitionsPart = mainPart.AddNewPart<StyleDefinitionsPart>();
                    Styles styles1 = new Styles();
                    DocDefaults docDefaults =
                        new DocDefaults(
                            new RunPropertiesDefault(new RunPropertiesBaseStyle(new RunFonts()
                            {
                                Ascii = "Times New Roman",
                                HighAnsi = "Times New Roman",
                                ComplexScript = "Times New Roman"
                            }, new FontSize() { Val = "24" },
                                new FontSizeComplexScript() { Val = "24" })),
                                new ParagraphPropertiesDefault(new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto }));
                    styles1.AppendChild(docDefaults);
                    styleDefinitionsPart.Styles = styles1;

                    mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();
                    DocumentFormat.OpenXml.Wordprocessing.Body body = mainPart.Document.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Body());
                    ParagraphProperties paragraphProperties1 = new ParagraphProperties(
                        new Justification() { Val = JustificationValues.Center },
                        new ParagraphMarkRunProperties(
                            new RunFonts()
                            {
                                Ascii = "Times New Roman",
                                HighAnsi = "Times New Roman",
                                ComplexScript = "Times New Roman"
                            },
                            new FontSize() { Val = "24" },
                            new FontSizeComplexScript() { Val = "24" }
                            ));

                    Paragraph para = body.AppendChild(new Paragraph());
                    para.AppendChild(paragraphProperties1);

                    Run run = para.AppendChild(new Run());

                    RunProperties runProperties1 = new RunProperties(
                        new Bold());

                    // String msg contains the text, "Hello, Word!"
                    run.AppendChild(runProperties1);
                    run.AppendChild(new Text("ПРИЛОЖЕНИЕ Ф"));
                    run.AppendChild(new Break());
                    run.AppendChild(new Text("Ведомость углов поворотов"));
                    run.AppendChild(new Break());

                    var table = new DocumentFormat.OpenXml.Wordprocessing.Table();
                    // Create a TableProperties object and specify its border information.
                    TableProperties tblProp = new TableProperties(
                        new TableWidth() { Width = "9782", Type = TableWidthUnitValues.Dxa },
                        new TableIndentation() { Width = -318, Type = TableWidthUnitValues.Dxa },
                        new TableBorders(
                            new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 },
                            new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4, Space = 0 }),
                        new DocumentFormat.OpenXml.Wordprocessing.TableStyle() { Val = "TableGrid" }
                        );

                    // Append the TableProperties object to the empty table.
                    table.AppendChild<TableProperties>(tblProp);

                    // Add 3 columns to the table.
                    TableGrid tg = new TableGrid(new GridColumn(), new GridColumn(), new GridColumn(), new GridColumn(),
                        new GridColumn(), new GridColumn(), new GridColumn());
                    table.AppendChild(tg);

                    TableRow tr1 = new TableRow(
                        new TableRowProperties(new TableRowHeight() { Val = 430 }),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1709" },
                                new VerticalMerge() { Val = MergedCellValues.Restart },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()),
                                new Run(new Text("Обозначение точки")))),
                        //new TableCellProperties(new TableCellWidth() {Type = TableWidthUnitValues.Pct, Width = "500"})
                        new TableCell(
                            new TableCellProperties(
                                new GridSpan() { Val = 2 },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center },
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "3922" }),
                            new Paragraph(
                                new ParagraphProperties(new Justification() { Val = JustificationValues.Center }),
                                new Run(new Text("Координаты точки")))),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1358" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center },
                                new VerticalMerge() { Val = MergedCellValues.Restart }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()),
                                new Run(new Text("Пикетаж")))),
                        new TableCell(
                            new TableCellProperties(
                                new GridSpan() { Val = 2 },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center },
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2368" }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()),
                                new Run(new Text("Угол")))),
                        new TableCell(new TableCellProperties(
                            new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "425" },
                            new VerticalMerge() { Val = MergedCellValues.Restart },
                            new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("Прямая вставка, м"))))
                        );
                    table.AppendChild(tr1);
                    TableRow tr2 = new TableRow(
                        new TableRowProperties(new TableRowHeight() { Val = 419 }),
                        new TableCell(new TableCellProperties(new VerticalMerge()), new Paragraph(new Run())),
                        new TableCell(
                            new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new ParagraphProperties(new Justification() { Val = JustificationValues.Center }), new Paragraph(new Run(new Text("Y")))),
                        new TableCell(
                            new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new ParagraphProperties(new Justification() { Val = JustificationValues.Center }), new Paragraph(new Run(new Text("X")))),
                        new TableCell(new TableCellProperties(new VerticalMerge()), new Paragraph(new Run())),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1260" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("Лево")))),
                        new TableCell(
                            new TableCellProperties(
                                new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "1108" },
                                new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }),
                            new Paragraph(new ParagraphProperties(GetCenterJustify()), new Run(new Text("Право")))),
                        new TableCell(new TableCellProperties(new VerticalMerge()), new Paragraph(new Run())));
                    table.AppendChild(tr2);

                    TableCellProperties tcp = new TableCellProperties(new GridSpan() { Val = 7 });

                    while (true)
                    {
                        double dist = 0, paste = 0;

                        table.AppendChild(new TableRow(
                            new TableCell(
                                new TableCellProperties(
                                    new GridSpan() { Val = 7 }),
                                    new Paragraph(
                                        new ParagraphProperties(
                                            new ParagraphMarkRunProperties(new Bold()),
                                            new Justification() { Val = JustificationValues.Center }),
                                            new Run(new RunProperties(
                                                new Bold()),
                                                new Text("Трасса"))))));

                        PromptEntityOptions peo = new PromptEntityOptions("\nВыбери polyline: ");
                        peo.SetRejectMessage("Можно только polyline.");
                        peo.AddAllowedClass(typeof(Polyline), true);
                        PromptEntityResult per = ed.GetEntity(peo);
                        if (per.Status != PromptStatus.OK) { break; }

                        PromptPointResult pPtRes;
                        PromptPointOptions pPtOpts = new PromptPointOptions("");
                        // Prompt for the start point
                        pPtOpts.Message = "\nВведи начало: ";
                        pPtRes = doc.Editor.GetPoint(pPtOpts);

                        PromptDoubleOptions getpik = new PromptDoubleOptions("\nВведи пикетаж (в формате числа, а не 0+00): ");
                        PromptDoubleResult getpikRes = doc.Editor.GetDouble(getpik);
                        dist = 100 * getpikRes.Value;

                        /*
                        PromptStringOptions pStrOpts = new PromptStringOptions("\nEnter your name: ");
                        pStrOpts.AllowSpaces = true;
                        PromptResult pStrRes = doc.Editor.GetString(pStrOpts);
                        Application.ShowAlertDialog("The name entered was: " + pStrRes.StringResult);
                         */

                        Point3d curr = pPtRes.Value, next = pPtRes.Value;
                        try
                        {
                            using (Transaction tr = db.TransactionManager.StartTransaction())
                            {
                                Polyline pline = (Polyline)tr.GetObject(per.ObjectId, OpenMode.ForRead);
                                if ((pPtRes.Value == pline.GetLineSegmentAt(0).StartPoint) || (pPtRes.Value == pline.GetLineSegmentAt(0).EndPoint))
                                    for (int i = 0; i < pline.NumberOfVertices - 2; i++)
                                    {
                                        TrassaRecord temp = new TrassaRecord();
                                        temp.Name = "ВТ" + (i + 1).ToString();

                                        LineSegment3d l1 = pline.GetLineSegmentAt(i);
                                        LineSegment3d l2 = pline.GetLineSegmentAt(i + 1);
                                        double angle = GetPolylineShape(l1, l2, pline.Normal);
                                        if (angle > Math.PI)
                                        {
                                            if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.StartPoint.X, l1.StartPoint.Y);
                                                next = l1.StartPoint;

                                                temp.CoordsX = l1.StartPoint.X.ToString("F");
                                                temp.CoordsY = l1.StartPoint.Y.ToString("F");
                                            }
                                            else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.EndPoint.X, l1.EndPoint.Y);
                                                next = l1.EndPoint;

                                                temp.CoordsX = l1.EndPoint.X.ToString("F");
                                                temp.CoordsY = l1.EndPoint.Y.ToString("F");
                                            }
                                            angle = -(angle - Math.PI * 2.0) * 180.0 / Math.PI;
                                            ed.WriteMessage("{0},{1:0}", (int)angle / 1, (angle % 1) * 60);

                                            temp.AngleT = TrassaRecord.Angle.Right;
                                            temp.AngleVal = ((int)angle / 1).ToString("F0") + "°" + ((angle % 1) * 60).ToString("F0") + "’";
                                        }
                                        else
                                        {
                                            if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.StartPoint.X, l1.StartPoint.Y);
                                                next = l1.StartPoint;

                                                temp.CoordsX = l1.StartPoint.X.ToString("F");
                                                temp.CoordsY = l1.StartPoint.Y.ToString("F");
                                            }
                                            else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.EndPoint.X, l1.EndPoint.Y);
                                                next = l1.EndPoint;

                                                temp.CoordsX = l1.EndPoint.X.ToString("F");
                                                temp.CoordsY = l1.EndPoint.Y.ToString("F");
                                            }
                                            angle = angle * 180.0 / Math.PI;
                                            ed.WriteMessage("{0},{1:0}", (int)angle / 1, (angle % 1) * 60);

                                            temp.AngleT = TrassaRecord.Angle.Left;
                                            temp.AngleVal = ((int)angle / 1).ToString("F0") + "°" + ((angle % 1) * 60).ToString("F0") + "’";
                                        }

                                        paste = curr.DistanceTo(next);
                                        dist += paste;
                                        curr = next;
                                        ed.WriteMessage(" {0:0.00} {1:0.00}", dist, paste);

                                        temp.Piketaz = ((int)dist / 100).ToString("F0") + "+" + (dist % 100).ToString("F");
                                        temp.DirectInsert = paste.ToString("F");

                                        tr2 = new TableRow(
                                            new TableRowProperties(new TableRowHeight() { Val = 300 }),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run(new Text(temp.DirectInsert))))
                                            );
                                        table.AppendChild(tr2);
                                        tr1 = new TableRow(
                                            new TableRowProperties(new TableRowHeight() { Val = 300 }),
                                            new TableCell(new Paragraph(new Run(new Text(temp.Name)))),
                                            new TableCell(new Paragraph(new Run(new Text(temp.CoordsX)))),
                                            new TableCell(new Paragraph(new Run(new Text(temp.CoordsY)))),
                                            new TableCell(new Paragraph(new Run(new Text(temp.Piketaz)))),
                                            new TableCell(new Paragraph(new Run(new Text((temp.AngleT == TrassaRecord.Angle.Left) ? temp.AngleVal.ToString() : "")))),
                                            new TableCell(new Paragraph(new Run(new Text((temp.AngleT == TrassaRecord.Angle.Right) ? temp.AngleVal.ToString() : "")))),
                                            new TableCell(new Paragraph(new Run()))
                                            );
                                        table.AppendChild(tr1);
                                    }
                                else
                                    for (int i = pline.NumberOfVertices - 3; i >= 0; i--)
                                    {
                                        TrassaRecord temp = new TrassaRecord();
                                        temp.Name = "ВУ" + (pline.NumberOfVertices - 2 - i).ToString();

                                        LineSegment3d l1 = pline.GetLineSegmentAt(i);
                                        LineSegment3d l2 = pline.GetLineSegmentAt(i + 1);
                                        double angle = GetPolylineShape(l1, l2, pline.Normal);
                                        if (angle > Math.PI)
                                        {
                                            if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.StartPoint.X, l1.StartPoint.Y);
                                                next = l1.StartPoint;

                                                temp.CoordsX = l1.StartPoint.X.ToString("F");
                                                temp.CoordsY = l1.StartPoint.Y.ToString("F");
                                            }
                                            else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.EndPoint.X, l1.EndPoint.Y);
                                                next = l1.EndPoint;

                                                temp.CoordsX = l1.EndPoint.X.ToString("F");
                                                temp.CoordsY = l1.EndPoint.Y.ToString("F");
                                            }
                                            angle = -(angle - Math.PI * 2.0) * 180.0 / Math.PI;
                                            ed.WriteMessage("{0},{1:0}", (int)angle / 1, (angle % 1) * 60);

                                            temp.AngleT = TrassaRecord.Angle.Left;
                                            temp.AngleVal = ((int)angle / 1).ToString("F0") + "°" + ((angle % 1) * 60).ToString("00") + "’";
                                        }
                                        else
                                        {
                                            if ((l1.StartPoint == l2.StartPoint) || (l1.StartPoint == l2.EndPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.StartPoint.X, l1.StartPoint.Y);
                                                next = l1.StartPoint;

                                                temp.CoordsX = l1.StartPoint.X.ToString("F");
                                                temp.CoordsY = l1.StartPoint.Y.ToString("F");
                                            }
                                            else if ((l1.EndPoint == l2.EndPoint) || (l1.EndPoint == l2.StartPoint))
                                            {
                                                ed.WriteMessage("\n({0:0.00}, {1:0.00}): ", l1.EndPoint.X, l1.EndPoint.Y);
                                                next = l1.EndPoint;

                                                temp.CoordsX = l1.EndPoint.X.ToString("F");
                                                temp.CoordsY = l1.EndPoint.Y.ToString("F");
                                            }
                                            angle = angle * 180.0 / Math.PI;
                                            ed.WriteMessage("{0},{1:0}", (int)angle / 1, (angle % 1) * 60);

                                            temp.AngleT = TrassaRecord.Angle.Right;
                                            temp.AngleVal = ((int)angle / 1).ToString("F0") + "°" + ((angle % 1) * 60).ToString("00") + "’";
                                        }

                                        paste = curr.DistanceTo(next);
                                        dist += paste;
                                        curr = next;
                                        ed.WriteMessage(" {0:0.00} {1:0.00}", dist, paste);

                                        temp.Piketaz = ((int)dist / 100).ToString("F0") + "+" + (dist % 100).ToString("F");
                                        temp.DirectInsert = paste.ToString("F");

                                        tr2 = new TableRow(
                                            new TableRowProperties(new TableRowHeight() { Val = 300 }),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run())),
                                            new TableCell(new Paragraph(new Run(new Text(temp.DirectInsert))))
                                            );
                                        table.AppendChild(tr2);
                                        tr1 = new TableRow(
                                            new TableRowProperties(new TableRowHeight() { Val = 300 }),
                                            new TableCell(new Paragraph(new Run(new Text(temp.Name)))),
                                            new TableCell(new Paragraph(new Run(new Text(temp.CoordsX)))),
                                            new TableCell(new Paragraph(new Run(new Text(temp.CoordsY)))),
                                            new TableCell(new Paragraph(new Run(new Text(temp.Piketaz)))),
                                            new TableCell(new Paragraph(new Run(new Text((temp.AngleT == TrassaRecord.Angle.Left) ? temp.AngleVal.ToString() : "")))),
                                            new TableCell(new Paragraph(new Run(new Text((temp.AngleT == TrassaRecord.Angle.Right) ? temp.AngleVal.ToString() : "")))),
                                            new TableCell(new Paragraph(new Run()))
                                            );
                                        table.AppendChild(tr1);
                                    }
                            }
                        }
                        catch
                        {
                            ed.WriteMessage("\nInvalid polyline.");
                        }
                    }

                    body.AppendChild(table);
                    body.AppendChild(
                        new SectionProperties(
                            new PageMargin()
                            {
                                Top = 1134,
                                Right = (UInt32Value)850U,
                                Bottom = 1134,
                                Left = (UInt32Value)1418U,
                                Header = (UInt32Value)708U,
                                Footer = (UInt32Value)708U,
                                Gutter = (UInt32Value)0U
                            }));
                    ed.WriteMessage("\nДокумент сохранен в D:\\tdoc.docx");
                }
                catch
                {
                    ed.WriteMessage("\nError.");
                }
            }
        }
示例#60
0
        private bool TryDisplayBarLadder()
        {
            Handle firstBarLineHandle = DrawBarLine(firstBarLine);
            IEnumerable<Handle> handles = null;
            PromptPointOptions options = new PromptPointOptions("\nWskaż rozrzut : ");
            options.Keywords.Add("K");
            options.Keywords.Default = "K";
            PromptPointResult result = editor.GetPoint(options);
            RemoveFirstBarLine(firstBarLineHandle);

            while (result.Status != PromptStatus.Keyword && result.Status != PromptStatus.Cancel && result.Status != PromptStatus.Error)
            {
                if (result.Status == PromptStatus.OK)
                {
                    spanPoint = result.Value;
                    RemoveBarLeader(handles);
                    handles = CreateOffsetLines();
                    result = editor.GetPoint(options);
                }
            }
            RemoveBarLeader(handles);

            if (result.Status == PromptStatus.Keyword && spanPoint.HasValue)
                return true;
            else
                return false;
        }