예제 #1
0
        private string promptFilter()
        {
            _Ed.PromptKeywordOptions promptOptions = new _Ed.PromptKeywordOptions("");
            promptOptions.Message = "\nWhat to print: ";
            promptOptions.Keywords.Add("A");
            promptOptions.Keywords.Add("B");
            promptOptions.Keywords.Add("C");
            promptOptions.Keywords.Add("D");
            promptOptions.Keywords.Add("E");
            promptOptions.Keywords.Add("EX");

            promptOptions.Keywords.Add("F");
            promptOptions.Keywords.Add("G");
            promptOptions.Keywords.Add("H");
            promptOptions.Keywords.Add("J");
            promptOptions.Keywords.Add("K");
            promptOptions.Keywords.Add("L");

            promptOptions.Keywords.Add("LX");
            promptOptions.Keywords.Add("M");
            promptOptions.Keywords.Add("N");
            promptOptions.Keywords.Add("NX");
            promptOptions.Keywords.Add("O");
            promptOptions.Keywords.Add("Q");

            promptOptions.Keywords.Add("R");
            promptOptions.Keywords.Add("S");
            promptOptions.Keywords.Add("SH");
            promptOptions.Keywords.Add("SX");
            promptOptions.Keywords.Add("T");
            promptOptions.Keywords.Add("U");

            promptOptions.Keywords.Add("V");
            promptOptions.Keywords.Add("W");
            promptOptions.Keywords.Add("X");
            promptOptions.Keywords.Add("XX");
            promptOptions.Keywords.Add("Z");

            promptOptions.Keywords.Add("ALL");
            promptOptions.Keywords.Add("SPEC");
            promptOptions.Keywords.Add("LAST");
            promptOptions.AllowNone = true;

            _Ed.PromptResult promptResult = _c.ed.GetKeywords(promptOptions);

            if (promptResult.Status == _Ed.PromptStatus.OK)
            {
                if (promptResult.StringResult == "")
                {
                    return("LAST");
                }
                else
                {
                    return(promptResult.StringResult);
                }
            }

            return("LAST");
        }
예제 #2
0
        private bool promptAddRebarToXml(_Mark u)
        {
            _Ed.PromptKeywordOptions promptOptions = new _Ed.PromptKeywordOptions("");
            promptOptions.Message = "\nAdd to XML: " + u.ToString();
            promptOptions.Keywords.Add("Yes");
            promptOptions.Keywords.Add("No");
            promptOptions.AllowNone = false;
            _Ed.PromptResult promptResult = _c.ed.GetKeywords(promptOptions);

            if (promptResult.Status == _Ed.PromptStatus.OK)
            {
                if (promptResult.StringResult == "Yes")
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public static LandRasterImage SelectingRasterOnClick(string key, string searchPath)
        {
            AcEd.Editor ed = AcApp.DocumentManager.MdiActiveDocument.Editor;

            LandRasterImage landRastr = null;

            AcEd.PromptPointOptions ppo = new AcEd.PromptPointOptions("\n" + key + " > Вкажіть точку вставки растру: ");
            ppo.UseBasePoint = false;
            var ppr = ed.GetPoint(ppo);

            if (ppr.Status == AcEd.PromptStatus.OK)
            {
                landRastr = new LandRasterImage();
                AcGe.Point3d tmpPt    = ppr.Value.TransformBy(landRastr.UCS.Inverse());
                int          valueKmX = (int)(tmpPt.X / 1000);
                int          valueKmY = (int)(tmpPt.Y / 1000);
                string       imgName  = (valueKmY + 1).ToString("00") + valueKmX.ToString("00");
                landRastr.ImageName = key + "-" + imgName;
                string[] filesName = Directory.GetFiles(searchPath, imgName + ".*");

                if (filesName.Length < 1)
                {
                    ed.WriteMessage("\n" + key + "В указаной точці знайдено растр '{0}.*'.", landRastr.ImageName);
                    return(null);
                }
                else if (filesName.Length == 1)
                {
                    landRastr.FileName = filesName[0];
                }
                else if (filesName.Length > 1)
                {
                    AcEd.PromptKeywordOptions pko = new AcEd.PromptKeywordOptions("\nВиберіть растр ");

                    for (int i = 0; i < filesName.Length; i++)
                    {
                        string nameRastr = Path.GetFileName(filesName[i]);
                        if (nameRastr.IndexOf(".bmp") > -1 ||
                            nameRastr.IndexOf(".tif") > -1 ||
                            nameRastr.IndexOf(".jpg") > -1)
                        {
                            pko.Keywords.Add("<" + nameRastr
                                             .Replace(".", "> ")
                                             .Replace('b', 'B')
                                             .Replace('j', 'J')
                                             .Replace('t', 'T'));
                        }
                    }

                    pko.Keywords.Default = Path.GetFileName("<" + filesName[0])
                                           .Replace(".", "> ")
                                           .Replace('b', 'B')
                                           .Replace('j', 'J').Replace('t', 'T');
                    pko.AllowNone = false;


                    AcEd.PromptResult pr = ed.GetKeywords(pko);

                    landRastr.FileName = searchPath + pr.StringResult.Replace(' ', '.');
                }


                landRastr.InsertPoint = new AcGe.Point3d(Convert.ToDouble(valueKmX) * 1000, Convert.ToDouble(valueKmY) * 1000, 0);
            }

            return(landRastr);
        }
예제 #4
0
        public static void BuildingRectangle()
        {
            try
            {
                AcDb.Database db = CurrentCAD.Database;
                AcEd.Editor   ed = CurrentCAD.Editor;

                AcEd.PromptKeywordOptions pko;
                AcEd.PromptPointOptions   ppt;
                AcEd.PromptPointResult    ppr;
                AcGe.Point3d basePoint;
                AcGe.Point3d diractionPoint;

                pko = new AcEd.PromptKeywordOptions("\nПобудова прямокутника");

                pko.Keywords.Add("по Діагоналі");
                pko.Keywords.Add("по Напрямку та діагоналі");
                pko.Keywords.Add("по Ширині та висота");
                pko.Keywords.Default = "по Ширині та висота";
                pko.AllowNone        = false;

                AcEd.PromptResult pkr = ed.GetKeywords(pko);

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

                MethodConstructingRectangle methodConstructing;

                if (pkr.StringResult == "Діагоналі")
                {
                    methodConstructing = MethodConstructingRectangle.Diagonal;
                }
                else if (pkr.StringResult == "Напрямку")
                {
                    methodConstructing = MethodConstructingRectangle.DirectionAndDiagonal;
                }
                else
                {
                    methodConstructing = MethodConstructingRectangle.HeightAndWidth;
                }

                ppt = new AcEd.PromptPointOptions("\nВкажіть першу точку прямокутника:");
                ppr = ed.GetPoint(ppt);
                if (ppr.Status != AcEd.PromptStatus.OK)
                {
                    return;
                }

                basePoint = ppr.Value;

                if (methodConstructing == MethodConstructingRectangle.Diagonal)
                {
                    diractionPoint = basePoint.Add(AcGe.Vector3d.XAxis);
                }
                else
                {
                    ppt = new AcEd.PromptPointOptions("\n");
                    if (methodConstructing == MethodConstructingRectangle.DirectionAndDiagonal)
                    {
                        ppt.Message = "\nВкажіть точку напрямку прямокутника:";
                    }
                    else if (methodConstructing == MethodConstructingRectangle.DirectionAndDiagonal)
                    {
                        ppt.Message = "\nВкажіть ширину прямокутника:";
                    }
                    ppt.UseBasePoint = true;
                    ppt.BasePoint    = basePoint;
                    ppr = ed.GetPoint(ppt);
                    if (ppr.Status != AcEd.PromptStatus.OK)
                    {
                        return;
                    }

                    diractionPoint = ppr.Value;
                }
                jigger = new RectangleJig(methodConstructing, basePoint, diractionPoint);
                ed.Drag(jigger);

                using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
                {
                    AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(db.CurrentSpaceId, AcDb.OpenMode.ForWrite);

                    Teigha.DatabaseServices.Polyline ent = new Teigha.DatabaseServices.Polyline();
                    ent.SetDatabaseDefaults();
                    for (int i = 0; i < jigger.Corners.Count; i++)
                    {
                        AcGe.Point3d pt3d = jigger.Corners[i];
                        AcGe.Point2d pt2d = new AcGe.Point2d(pt3d.X, pt3d.Y);
                        ent.AddVertexAt(i, pt2d, 0, db.Plinewid, db.Plinewid);
                    }
                    ent.Closed = true;
                    ent.TransformBy(jigger.UCS);
                    btr.AppendEntity(ent);
                    tr.AddNewlyCreatedDBObject(ent, true);

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                CurrentCAD.Editor.WriteMessage(ex.ToString());
            }
        }