예제 #1
0
        static public void mainTheodoliteStrokeParser()
        {
            // Получение текущего документа и базы данных
            App.Document acDoc = App.Application.DocumentManager.MdiActiveDocument;
            if (acDoc == null)
            {
                return;
            }

            SettingsParser settings = SettingsParser.getInstance();

            if (settings.Update())
            {
                return;
            }


            Ed.Editor acEd = acDoc.Editor;

            //тут запросить масштаб
            //Предполагается всего 4 вида стандартных масштабов - 1:500, 1:1000, 1:2000, 1:5000.
            Ed.PromptKeywordOptions pKeyOpts = new Ed.PromptKeywordOptions("");
            pKeyOpts.Message = "\nEnter an option: 1/";

            foreach (Scale i in settings.ScaleList)
            {
                pKeyOpts.Keywords.Add(i.Number.ToString());
            }

            pKeyOpts.AllowNone = false;
            pKeyOpts.AppendKeywordsToMessage = true;

            Ed.PromptResult pKeyRes = acDoc.Editor.GetKeywords(pKeyOpts);
            if (pKeyRes.Status != Ed.PromptStatus.OK)
            {
                return;
            }

            settings._Scale = settings.ScaleList.FirstOrDefault(s => s.Number == int.Parse(pKeyRes.StringResult));
            Model.Init();

            bool goOn = true; //Продолжать ли выбор

            do
            {
                Ed.PromptEntityOptions opt = new Ed.PromptEntityOptions("\n Select polyline: ");
                opt.AllowNone = false;
                opt.AllowObjectOnLockedLayer = false;
                opt.SetRejectMessage("\nNot a pline try again: ");
                opt.AddAllowedClass(typeof(Db.Polyline), true);

                Ed.PromptEntityResult res = acEd.GetEntity(opt);

                goOn = (res.Status == Ed.PromptStatus.OK) ? Model.GetData(res.ObjectId) : false;
            } while (goOn);

            Model.OutPutData();
        }
예제 #2
0
        public static void PlotRegion()
        {
            Ap.Document doc = cad.DocumentManager.MdiActiveDocument;
            if (doc == null || doc.IsDisposed)
            {
                return;
            }

            Ed.Editor   ed = doc.Editor;
            Db.Database db = doc.Database;

            using (doc.LockDocument())
            {
                Ed.PromptEntityOptions peo = new Ed.PromptEntityOptions(
                    "\nSelect a region"
                    );

                peo.SetRejectMessage("\nIt is not a region."
                                     );
                peo.AddAllowedClass(typeof(Db.Region), false);

                Ed.PromptEntityResult per = ed.GetEntity(peo);

                if (per.Status != Ed.PromptStatus.OK)
                {
                    ed.WriteMessage("\nCommand canceled.\n");
                    return;
                }

                Db.ObjectId regionId = per.ObjectId;

                Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32
                                                                .SaveFileDialog();
                saveFileDialog.Title =
                    "PDF file name";
                saveFileDialog.Filter = "PDF-files|*.pdf";
                bool?result = saveFileDialog.ShowDialog();

                if (!result.HasValue || !result.Value)
                {
                    ed.WriteMessage("\nCommand canceled.");
                    return;
                }

                String pdfFileName = saveFileDialog.FileName;

                PlotRegion(regionId, "DWG To PDF.pc3",
                           "ISO_A4_(210.00_x_297.00_MM)", pdfFileName);

                ed.WriteMessage("\nThe \"{0}\" file created.\n", pdfFileName);
            }
        }
예제 #3
0
        public static void DOinBlock()
        {
            App.Document dwg = App.Application.DocumentManager.MdiActiveDocument;
            Ed.Editor    ed  = dwg.Editor;

            //Ask user to select a block. In real world, I use code
            //to select all targeting blocks by its name, so that
            //user does not have to select block manually
            Ed.PromptEntityOptions opt = new Ed.PromptEntityOptions("\nSelect a block:");
            opt.SetRejectMessage("\nInvalid: not a block.");
            opt.AddAllowedClass(typeof(Db.BlockReference), true);
            Ed.PromptEntityResult res = ed.GetEntity(opt);

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

            SetDrawOrderInBlock(dwg, res.ObjectId);
            ed.Regen();

            Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
        }