Beispiel #1
0
        Stream(ArrayList data, PromptEditorOptions opts)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PromptEditorOptions)));

            PromptCornerOptions promptCornerOpts = opts as PromptCornerOptions;

            if (promptCornerOpts != null)
            {
                Stream(data, promptCornerOpts);
                return;
            }

            PromptStringOptions promptStrOpts = opts as PromptStringOptions;

            if (promptStrOpts != null)
            {
                Stream(data, promptStrOpts);
                return;
            }

            PromptKeywordOptions promptKwordOpts = opts as PromptKeywordOptions;

            if (promptKwordOpts != null)
            {
                Stream(data, promptKwordOpts);
                return;
            }

            PromptNumericalOptions promptNumpericalOpts = opts as PromptNumericalOptions;

            if (promptNumpericalOpts != null)
            {
                Stream(data, promptNumpericalOpts);
                return;
            }

            PromptEntityOptions promptEntOpts = opts as PromptEntityOptions;

            if (promptEntOpts != null)
            {
                Stream(data, promptEntOpts);
                return;
            }

            PromptAngleOptions promptAngleOpts = opts as PromptAngleOptions;

            if (promptAngleOpts != null)
            {
                Stream(data, promptAngleOpts);
                return;
            }

            PromptDragOptions promptDragOpts = opts as PromptDragOptions;

            if (promptDragOpts != null)
            {
                Stream(data, promptDragOpts);
                return;
            }
        }
Beispiel #2
0
        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());
        }
Beispiel #3
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);
        }
Beispiel #4
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;
        }
Beispiel #5
0
        private void SelectRange()
        {
            logger.Debug("点击选择range按钮");

            Document acDoc    = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb  = acDoc.Database;
            Editor   acEditor = acDoc.Editor;

            //如果没有记录,那么就提示如何放置产品,并在选择的点上进行绘制
            Point3d           ptStart = Point3d.Origin;
            PromptPointResult rpr     = acEditor.GetPoint("选择起点\n");

            if (rpr.Status == PromptStatus.OK)
            {
                ptStart = rpr.Value;
                Point3d             ptEnd   = Point3d.Origin;
                PromptCornerOptions options = new PromptCornerOptions("选择终点", ptStart);
                PromptPointResult   i       = acEditor.GetCorner(options);
                if (i.Status == PromptStatus.OK)
                {
                    ptEnd = i.Value;

                    double width  = Math.Abs(ptStart.X - ptEnd.X);
                    double height = Math.Abs(ptStart.Y - ptEnd.Y);

                    this.SelectedItem.Width.PropertyValue  = Math.Round(width, 3).ToString();
                    this.SelectedItem.Height.PropertyValue = Math.Round(height, 3).ToString();
                }
            }

            logger.Debug("未选择产品的放置点");
            return;
        }
Beispiel #6
0
        getCorners(out Point3d corner1, out Point3d corner2)
        {
            Editor ed = BaseObjs._editor;

            PromptPointResult prRes = ed.GetPoint("\nSelect one corner");

            if (prRes.Status != PromptStatus.OK)
            {
                corner1 = prRes.Value;
                corner2 = prRes.Value;
                return(false);
            }

            corner1 = prRes.Value;
            PromptCornerOptions prOpts = new PromptCornerOptions(string.Format("\n{0}", "Select another corner"), corner1);

            prOpts.AllowNone     = true;
            prOpts.UseDashedLine = true;

            prRes = ed.GetCorner(prOpts);
            if (prRes.Status != PromptStatus.OK)
            {
                corner2 = prRes.Value;
                return(false);
            }
            corner2 = prRes.Value;

            return(true);
        }
Beispiel #7
0
        public Polyline3d GetRegion(string firstMessage = "请选择区域", string secondMessage = "请选择区域")
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            using (DocumentLock acLckDoc = doc.LockDocument())
            {
                Editor  editor     = doc.Editor;
                Point3d firstPoint = GetPoint(firstMessage);
                if (firstPoint == Point3d.Origin)
                {
                    //用户取消操作
                    return(null);
                }
                Point3d             secondPoint;
                PromptCornerOptions options = new PromptCornerOptions(secondMessage, firstPoint);
                PromptPointResult   i       = editor.GetCorner(options);
                if (i.Status == PromptStatus.OK)
                {
                    secondPoint = i.Value;
                }
                else
                {
                    return(null);
                }
                Point3dCollection points = new Point3dCollection();
                points.Add(firstPoint);
                points.Add(new Point3d(secondPoint.X, firstPoint.Y, 0));
                points.Add(secondPoint);
                points.Add(new Point3d(firstPoint.X, secondPoint.Y, 0));
                return(new Polyline3d(Poly3dType.SimplePoly, points, true));
            }
        }
Beispiel #8
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");
                }
            }
        }
Beispiel #9
0
        GetCorners(out Point3d corner1, out Point3d corner2)
        {
            Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor;

            PromptPointResult prRes = ed.GetPoint("\nSelect one corner");

            if (prRes.Status != PromptStatus.OK)
            {
                corner1 = prRes.Value;
                corner2 = prRes.Value;
                return(false);
            }

            corner1 = prRes.Value;
            PromptCornerOptions prOpts = new PromptCornerOptions(string.Format("\n{0}", "Select another corner"), corner1);

            prOpts.AllowNone     = true;
            prOpts.UseDashedLine = true;

            prRes = ed.GetCorner(prOpts);
            if (prRes.Status != PromptStatus.OK)
            {
                corner2 = prRes.Value;
                return(false);
            }
            corner2 = prRes.Value;

            return(true);
        }
Beispiel #10
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);
        }
Beispiel #11
0
        static public void plotterPDF()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                //ask user for print window
                Point3d            first;
                PromptPointOptions ppo = new PromptPointOptions("\nSelect First corner of plot area: ");
                ppo.AllowNone = false;
                PromptPointResult ppr = ed.GetPoint(ppo);
                if (ppr.Status == PromptStatus.OK)
                {
                    first = ppr.Value;
                }
                else
                {
                    return;
                }

                Point3d             second;
                PromptCornerOptions pco = new PromptCornerOptions("\nSelect second corner of the plot area.", first);
                ppr = ed.GetCorner(pco);
                if (ppr.Status == PromptStatus.OK)
                {
                    second = ppr.Value;
                }
                else
                {
                    return;
                }

                //convert from UCS to DCS
                Extents2d window = coordinates(first, second);

                //set up the plotter
                PlotInfo pi = plotSetUp(window, tr, db, ed, true, true);

                string fileName         = "PDF";
                PromptStringOptions pso = new PromptStringOptions("Enter file Name: ");
                pso.AllowSpaces = true;
                PromptResult res = ed.GetString(pso);
                if (res.Status == PromptStatus.OK)
                {
                    fileName = res.StringResult;
                }
                else
                {
                    return;
                }

                //call plotter engine to run
                plotEngine(pi, fileName, doc, ed, true);

                tr.Dispose();
            }
        }
Beispiel #12
0
        static public void plotterscaletofit()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                //ask user for print window
                Point3d            first;
                PromptPointOptions ppo = new PromptPointOptions("\nSelect First corner of plot area: ");
                ppo.AllowNone = false;
                PromptPointResult ppr = ed.GetPoint(ppo);
                if (ppr.Status == PromptStatus.OK)
                {
                    first = ppr.Value;
                }
                else
                {
                    return;
                }

                Point3d             second;
                PromptCornerOptions pco = new PromptCornerOptions("\nSelect second corner of the plot area.", first);
                ppr = ed.GetCorner(pco);
                if (ppr.Status == PromptStatus.OK)
                {
                    second = ppr.Value;
                }
                else
                {
                    return;
                }

                //convert from UCS to DCS
                Extents2d window = coordinates(first, second);

                //if the current view is paperspace then need to set up a viewport first
                if (LayoutManager.Current.CurrentLayout != "Model")
                {
                }

                //set up the plotter
                PlotInfo pi = plotSetUp(window, tr, db, ed, true, false);

                //call plotter engine to run
                plotEngine(pi, "Nameless", doc, ed, false);

                tr.Dispose();
            }
        }
Beispiel #13
0
        /// <summary>
        /// 获取用户输入的矩形角点区域
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="basePoint">The first point.</param>
        /// <returns>The point.</returns>
        public static Point3d getCorner(string message, Point3d basePoint)
        {
            var opt = new PromptCornerOptions(message, basePoint)
            {
                AllowNone = true
            };
            var res = GoatDB.ed.GetCorner(opt);

            if (res.Status == PromptStatus.OK)
            {
                return(res.Value);
            }
            return(Constant.NullPoint3d);
        }
Beispiel #14
0
        /// <summary>
        /// Get corner point.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="basePoint">The first point.</param>
        /// <returns>The point.</returns>
        public static Point3d GetCorner(string message, Point3d basePoint)
        {
            var ed  = Application.DocumentManager.MdiActiveDocument.Editor;
            var opt = new PromptCornerOptions(message, basePoint)
            {
                AllowNone = true
            };                                                                          // mod 20140527
            var res = ed.GetCorner(opt);

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

            return(Algorithms.NullPoint3d);
        }
Beispiel #15
0
        /// <summary>
        /// 获取用户输入的矩形角点区域
        /// </summary>
        /// <param name="baseword">基点提示</param>
        /// <param name="targetword">角点提示</param>
        /// /// <returns>用户输入的矩形角点区域</returns>
        public static Extents3d GetCorner(string baseword, string targetword)
        {
            Editor              ed       = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Point3d             basept   = GetPoint(baseword);
            Point3d             targetpt = new Point3d();
            PromptCornerOptions options  = new PromptCornerOptions(targetword, basept);
            PromptPointResult   i        = ed.GetCorner(options);

            if (i.Status == PromptStatus.OK)
            {
                targetpt = i.Value;
            }
            Extents3d ext = new Extents3d();

            ext.AddPoint(targetpt);
            ext.AddPoint(basept);
            return(ext);
        }
Beispiel #16
0
        Stream(ArrayList data, PromptCornerOptions opts)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PromptCornerOptions)));

            data.Add(new Snoop.Data.Bool("Allow arbitrary input", opts.AllowArbitraryInput));
            data.Add(new Snoop.Data.Bool("Allow none", opts.AllowNone));
            data.Add(new Snoop.Data.Point3d("Base point", opts.BasePoint));
            data.Add(new Snoop.Data.Bool("Limits checked", opts.LimitsChecked));
            data.Add(new Snoop.Data.Bool("Use dashed line", opts.UseDashedLine));

            PromptPointOptions promptPtOpts = opts as PromptPointOptions;

            if (promptPtOpts != null)
            {
                Stream(data, promptPtOpts);
                return;
            }
        }
Beispiel #17
0
        /// <summary>
        /// 사용자로부터 구역을 선택받습니다.
        /// </summary>
        /// <param name="BasePoint">기준점 입니다.</param>
        /// <param name="message">입력 전, 프롬프트에 표시할 메시지 입니다.</param>
        /// <returns></returns>
        public static Point3d GetCorner(Point3d BasePoint, string message = "구역 선택")
        {
            ActivateApplication();

            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            PromptCornerOptions pco = new PromptCornerOptions("\n" + message, BasePoint);

            PromptPointResult ppr = ed.GetCorner(pco);

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

            return(NullPoint3d);
        }
Beispiel #18
0
        public void GetPost()
        {
            Document            doc         = Application.DocumentManager.MdiActiveDocument;
            Editor              ed          = doc.Editor;
            PromptStringOptions prmptStrOpt = new PromptStringOptions("\n\n Type RedditCAD Post ID : ");
            PromptResult        prmpRes     = ed.GetString(prmptStrOpt);
            string              postId      = prmpRes.StringResult.ToUpper();

            if (PostIds.Contains(postId))
            {
                EntityData          dimStyles       = new EntityData();
                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);
                RedditCAD.FormatRedditDim(dimStyles, result.Value, prmptCnrResult.Value);
                RedditCAD.PlotPost(dimStyles, postId);
            }
            else
            {
                ed.WriteMessage("\n\n Invalid AutoCAD.Reddit Post Id..");
            }
        }
Beispiel #19
0
        static public void ZoomWindow()
        {
            Document doc =

                Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor ed = doc.Editor;


            // Get the window coordinates


            PromptPointOptions ppo =

                new PromptPointOptions(

                    "\nSpecify first corner:"

                    );


            PromptPointResult ppr =

                ed.GetPoint(ppo);


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


            Point3d min = ppr.Value;


            PromptCornerOptions pco =

                new PromptCornerOptions(

                    "\nSpecify opposite corner: ",

                    ppr.Value

                    );


            ppr = ed.GetCorner(pco);


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


            Point3d max = ppr.Value;


            // Call out helper function

            // [Change this to ZoomWin2 or WoomWin3 to

            // use different zoom techniques]


            //ZoomWin(ed, min, max);
            Plan2Ext.Globs.Zoom(new Point3d(min.X, min.Y, 0.0), new Point3d(max.X, max.Y, 0), new Point3d(), 1.0);
        }
Beispiel #20
0
 public static IAcedCmdArg Argument(PromptCornerOptions options)
 {
     return new PromptCornerArgument(options);
 }
Beispiel #21
0
        public void plottoPdfUseWindows()
        {
            Document doc =

                Application.DocumentManager.MdiActiveDocument;

            Editor ed = doc.Editor;

            Database db = doc.Database;


            Transaction tr =

                db.TransactionManager.StartTransaction();
            string blockName = "A01";

            TypedValue[]    tvs = new TypedValue[] { new TypedValue(0, "INSERT"), new TypedValue(2, blockName) };
            SelectionFilter sf  = new SelectionFilter(tvs);

            using (tr)
            {
                try
                {
                    PromptPointOptions ppo = new PromptPointOptions("\n\tSpecify a first corner: ");
                    PromptPointResult  ppr = ed.GetPoint(ppo);
                    if (ppr.Status != PromptStatus.OK)
                    {
                        return;
                    }
                    PromptCornerOptions pco = new PromptCornerOptions("\n\tOther corner: ", ppr.Value);
                    PromptPointResult   pcr = ed.GetCorner(pco);
                    if (pcr.Status != PromptStatus.OK)
                    {
                        return;
                    }
                    Point3d pt1 = ppr.Value;
                    Point3d pt2 = pcr.Value;
                    if (pt1.X == pt2.X || pt1.Y == pt2.Y)
                    {
                        ed.WriteMessage("\nInvalid point specification");
                        return;
                    }

                    PromptSelectionResult res;
                    res = ed.SelectWindow(pt1, pt2, sf);
                    Log4NetHelper.WriteInfoLog("pt1 pt2位置\n");
                    Log4NetHelper.WriteInfoLog(pt1 + "\n");
                    Log4NetHelper.WriteInfoLog(pt2 + "\n");
                    if (res.Status != PromptStatus.OK)
                    {
                        return;
                    }
                    SelectionSet sset = res.Value;
                    if (sset.Count == 0)
                    {
                        return;
                    }
                    BlockReference br = null;
                    foreach (SelectedObject obj in sset)
                    {
                        // ed.WriteMessage("\nhas data");
                        br = GetBlockReference(obj, tr);

                        //Log4NetHelper.WriteInfoLog(br.BlockName + "\n");
                        //Log4NetHelper.WriteInfoLog(br.Name+"\n");
                        //Log4NetHelper.WriteInfoLog(br.Bounds + "\n");
                        //Log4NetHelper.WriteInfoLog(br.Position + "\n");
                        //Log4NetHelper.WriteInfoLog(br.BlockTransform + "\n");
                        //Log4NetHelper.WriteInfoLog(br.BlockUnit + "\n");
                        //Log4NetHelper.WriteInfoLog("***********************\n");
                        //Log4NetHelper.WriteInfoLog(br.GeometricExtents.MinPoint + "\n");
                        //Log4NetHelper.WriteInfoLog("66666666666666666666666666\n");
                        //Log4NetHelper.WriteInfoLog(br.GeometricExtents.MaxPoint + "\n");
                        //Log4NetHelper.WriteInfoLog("***********************\n");
                        //Log4NetHelper.WriteInfoLog("-----------------------------\n");
                        PlotOnePaper(db, doc, br, "DWG To PDF.pc3",
                                     "A01 (1486.00 x 841.00 MM)", "111.pdf");
                    }
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage(ex.Message + "\n" + ex.StackTrace);
                }
            }
        }
Beispiel #22
0
        public void TcREC2()
        {
            int    num;
            int    num12;
            object obj;

            try
            {
                ProjectData.ClearProjectError();
                num = 2;
                Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
                Database database          = mdiActiveDocument.Database;
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    BlockTable         blockTable         = (BlockTable)transaction.GetObject(database.BlockTableId, 0);
                    BlockTableRecord   blockTableRecord   = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], 1);
                    PromptPointOptions promptPointOptions = new PromptPointOptions("");
                    promptPointOptions.Message = "\n请选择其中一个角点: ";
                    PromptPointResult   promptPointResult   = mdiActiveDocument.Editor.GetPoint(promptPointOptions);
                    Point3d             point3d             = promptPointResult.Value;
                    PromptCornerOptions promptCornerOptions = new PromptCornerOptions("请选择一个对角点:", point3d);
                    promptPointResult = mdiActiveDocument.Editor.GetCorner(promptCornerOptions);
                    Point3d point3d2 = promptPointResult.Value;
                    Point3d point3d3;
                    point3d3..ctor(Math.Min(point3d.get_Coordinate(0), point3d2.get_Coordinate(0)), Math.Min(point3d.get_Coordinate(1), point3d2.get_Coordinate(1)), 0.0);
                    Point3d point3d4;
                    point3d4..ctor(Math.Max(point3d.get_Coordinate(0), point3d2.get_Coordinate(0)), Math.Max(point3d.get_Coordinate(1), point3d2.get_Coordinate(1)), 0.0);
                    point3d  = point3d3;
                    point3d2 = point3d4;
                    Point3d point3d5;
                    point3d5..ctor(point3d.get_Coordinate(0), point3d2.get_Coordinate(1), 0.0);
                    Point3d point3d6;
                    point3d6..ctor(point3d2.get_Coordinate(0), point3d.get_Coordinate(1), 0.0);
                    Polyline polyline = new Polyline();
                    polyline.SetDatabaseDefaults();
                    Polyline polyline2 = polyline;
                    int      num2      = 0;
                    Point2d  point2d;
                    point2d..ctor(point3d.get_Coordinate(0), point3d.get_Coordinate(1));
                    polyline2.AddVertexAt(num2, point2d, 0.0, 0.0, 0.0);
                    Polyline polyline3 = polyline;
                    int      num3      = 1;
                    point2d..ctor(point3d5.get_Coordinate(0), point3d5.get_Coordinate(1));
                    polyline3.AddVertexAt(num3, point2d, 0.0, 0.0, 0.0);
                    Polyline polyline4 = polyline;
                    int      num4      = 2;
                    point2d..ctor(point3d2.get_Coordinate(0), point3d2.get_Coordinate(1));
                    polyline4.AddVertexAt(num4, point2d, 0.0, 0.0, 0.0);
                    Polyline polyline5 = polyline;
                    int      num5      = 3;
                    point2d..ctor(point3d6.get_Coordinate(0), point3d6.get_Coordinate(1));
                    polyline5.AddVertexAt(num5, point2d, 0.0, 0.0, 0.0);
                    polyline.Closed = true;
                    blockTableRecord.AppendEntity(polyline);
                    transaction.AddNewlyCreatedDBObject(polyline, true);
                    point3d  = polyline.GeometricExtents.MinPoint;
                    point3d2 = polyline.GeometricExtents.MaxPoint;
                    point3d5..ctor(point3d.get_Coordinate(0), point3d2.get_Coordinate(1), 0.0);
                    double  num6 = point3d.DistanceTo(point3d5);
                    double  num7 = point3d.DistanceTo(point3d6);
                    Point3d pointAngle;
                    if (num6 > num7)
                    {
                        pointAngle = CAD.GetPointAngle(point3d5, num7 / 5.0, -45.0);
                    }
                    else
                    {
                        pointAngle = CAD.GetPointAngle(point3d5, num6 / 5.0, -45.0);
                    }
                    polyline = new Polyline();
                    Polyline polyline6 = polyline;
                    int      num8      = 0;
                    point2d..ctor(point3d.get_Coordinate(0), point3d.get_Coordinate(1));
                    polyline6.AddVertexAt(num8, point2d, 0.0, 0.0, 0.0);
                    Polyline polyline7 = polyline;
                    int      num9      = 1;
                    point2d..ctor(point3d5.get_Coordinate(0), point3d5.get_Coordinate(1));
                    polyline7.AddVertexAt(num9, point2d, 0.0, 0.0, 0.0);
                    Polyline polyline8 = polyline;
                    int      num10     = 2;
                    point2d..ctor(point3d2.get_Coordinate(0), point3d2.get_Coordinate(1));
                    polyline8.AddVertexAt(num10, point2d, 0.0, 0.0, 0.0);
                    Polyline polyline9 = polyline;
                    int      num11     = 3;
                    point2d..ctor(pointAngle.get_Coordinate(0), pointAngle.get_Coordinate(1));
                    polyline9.AddVertexAt(num11, point2d, 0.0, 0.0, 0.0);
                    polyline.Closed = true;
                    blockTableRecord.AppendEntity(polyline);
                    transaction.AddNewlyCreatedDBObject(polyline, true);
                    transaction.Commit();
                }
                goto IL_4A2;
IL_44B:
                Interaction.MsgBox(Information.Err().Description, MsgBoxStyle.OkOnly, null);
                goto IL_4A2;
IL_45F:
                num12 = -1;
                @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
                IL_474 :;
            }
            catch when(endfilter(obj is Exception & num != 0 & num12 == 0))
            {
                Exception ex = (Exception)obj2;

                goto IL_45F;
            }
            throw ProjectData.CreateProjectError(-2146828237);
IL_4A2:
            if (num12 != 0)
            {
                ProjectData.ClearProjectError();
            }
        }
Beispiel #23
0
        public void TcLTTL()
        {
            int    num;
            int    num10;
            object obj;

            try
            {
                ProjectData.ClearProjectError();
                num = 2;
                Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
                Database database          = mdiActiveDocument.Database;
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    BlockTable         blockTable         = (BlockTable)transaction.GetObject(database.BlockTableId, 0);
                    BlockTableRecord   blockTableRecord   = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], 1);
                    PromptPointOptions promptPointOptions = new PromptPointOptions("");
                    promptPointOptions.Message = "\n请选择其中一个角点: ";
                    PromptPointResult promptPointResult = mdiActiveDocument.Editor.GetPoint(promptPointOptions);
                    if (promptPointResult.Status == 5100)
                    {
                        Point3d             point3d             = promptPointResult.Value;
                        PromptCornerOptions promptCornerOptions = new PromptCornerOptions("请选择一个对角点:", point3d);
                        promptPointResult = mdiActiveDocument.Editor.GetCorner(promptCornerOptions);
                        if (promptPointResult.Status == 5100)
                        {
                            Point3d value = promptPointResult.Value;
                            Point3d point3d2;
                            point3d2..ctor(Math.Min(point3d.get_Coordinate(0), value.get_Coordinate(0)), Math.Min(point3d.get_Coordinate(1), value.get_Coordinate(1)), 0.0);
                            Point3d point3d3;
                            point3d3..ctor(Math.Max(point3d.get_Coordinate(0), value.get_Coordinate(0)), Math.Max(point3d.get_Coordinate(1), value.get_Coordinate(1)), 0.0);
                            point3d = point3d2;
                            Point3d point3d4 = point3d3;
                            value..ctor(point3d.get_Coordinate(0), point3d4.get_Coordinate(1), 0.0);
                            Point3d point3d5;
                            point3d5..ctor(point3d4.get_Coordinate(0), point3d.get_Coordinate(1), 0.0);
                            Polyline polyline = new Polyline();
                            polyline.SetDatabaseDefaults();
                            Polyline polyline2 = polyline;
                            int      num2      = 0;
                            Point2d  point2d;
                            point2d..ctor(point3d.get_Coordinate(0), point3d.get_Coordinate(1));
                            polyline2.AddVertexAt(num2, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline3 = polyline;
                            int      num3      = 1;
                            point2d..ctor(value.get_Coordinate(0), value.get_Coordinate(1));
                            polyline3.AddVertexAt(num3, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline4 = polyline;
                            int      num4      = 2;
                            point2d..ctor(point3d4.get_Coordinate(0), point3d4.get_Coordinate(1));
                            polyline4.AddVertexAt(num4, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline5 = polyline;
                            int      num5      = 3;
                            point2d..ctor(point3d5.get_Coordinate(0), point3d5.get_Coordinate(1));
                            polyline5.AddVertexAt(num5, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline6 = polyline;
                            int      num6      = 4;
                            point2d..ctor(point3d.get_Coordinate(0), point3d.get_Coordinate(1));
                            polyline6.AddVertexAt(num6, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline7 = polyline;
                            int      num7      = 5;
                            point2d..ctor(point3d4.get_Coordinate(0), point3d4.get_Coordinate(1));
                            polyline7.AddVertexAt(num7, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline8 = polyline;
                            int      num8      = 6;
                            point2d..ctor(value.get_Coordinate(0), value.get_Coordinate(1));
                            polyline8.AddVertexAt(num8, point2d, 0.0, 0.0, 0.0);
                            Polyline polyline9 = polyline;
                            int      num9      = 7;
                            point2d..ctor(point3d5.get_Coordinate(0), point3d5.get_Coordinate(1));
                            polyline9.AddVertexAt(num9, point2d, 0.0, 0.0, 0.0);
                            polyline.Closed = true;
                            blockTableRecord.AppendEntity(polyline);
                            transaction.AddNewlyCreatedDBObject(polyline, true);
                            transaction.Commit();
                        }
                    }
                }
                goto IL_410;
IL_3B9:
                Interaction.MsgBox(Information.Err().Description, MsgBoxStyle.OkOnly, null);
                goto IL_410;
IL_3CD:
                num10 = -1;
                @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
                IL_3E2 :;
            }
            catch when(endfilter(obj is Exception & num != 0 & num10 == 0))
            {
                Exception ex = (Exception)obj2;

                goto IL_3CD;
            }
            throw ProjectData.CreateProjectError(-2146828237);
IL_410:
            if (num10 != 0)
            {
                ProjectData.ClearProjectError();
            }
        }
        private void SelectRange()
        {
            logger.Debug("点击选择range按钮");

            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Editor acEditor = acDoc.Editor;

            //如果没有记录,那么就提示如何放置产品,并在选择的点上进行绘制
            Point3d ptStart = Point3d.Origin;
            PromptPointResult rpr = acEditor.GetPoint("选择起点\n");
            if (rpr.Status == PromptStatus.OK)
            {
                ptStart = rpr.Value;
                Point3d ptEnd = Point3d.Origin;
                PromptCornerOptions options = new PromptCornerOptions("选择终点", ptStart);
                PromptPointResult i = acEditor.GetCorner(options);
                if (i.Status == PromptStatus.OK)
                {
                    ptEnd = i.Value;

                    double width = Math.Abs(ptStart.X - ptEnd.X);
                    double height = Math.Abs(ptStart.Y - ptEnd.Y);

                    this.SelectedItem.Width.PropertyValue = Math.Round(width, 3).ToString();
                    this.SelectedItem.Height.PropertyValue = Math.Round(height, 3).ToString();
                }
            }

            logger.Debug("未选择产品的放置点");
            return;
        }
Beispiel #25
0
 public static IAcedCmdArg Argument(PromptCornerOptions options)
 {
     return(new PromptCornerArgument(options));
 }
        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();
        }
Beispiel #27
0
 public PromptCornerArgument(PromptCornerOptions promptOptions)
 {
     _promptOptions = promptOptions;
 }