public static void CreateBeam() { _AcGe.Point3d p0, p1, pside; // // Get some user input: // _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor; _AcEd.PromptPointOptions ppo = new _AcEd.PromptPointOptions("\nSelect start point of beam: "); ppo.UseBasePoint = false; _AcEd.PromptPointResult ppres = ed.GetPoint(ppo); if (ppres.Status != _AcEd.PromptStatus.OK) { return; } p0 = ppres.Value; ppo.UseBasePoint = true; ppo.BasePoint = p0; ppo.Message = "\nSelect end point of beam: "; ppres = ed.GetPoint(ppo); if (ppres.Status != _AcEd.PromptStatus.OK) { return; } p1 = ppres.Value; ppo.BasePoint = p1; ppo.Message = "\nSelect side of beam drawing direction (Press ESC for on centre line): "; ppres = ed.GetPoint(ppo); if (ppres.Status == _AcEd.PromptStatus.Cancel) { pside = new Teigha.Geometry.Point3d(); // send empty point, could do better here with keywords for the propmt. } else { pside = ppres.Value; } // // Create the beam: // BeamData beamData = new BeamData(200, 120, 6000, p0, p1, pside); BeamDrawer beamDrawer = new BeamDrawer(beamData); beamDrawer.DrawBeam(); }
static public void ZoomWindow() { _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument; _AcDb.Database db = doc.Database; _AcEd.Editor ed = doc.Editor; // Get the window coordinates _AcEd.PromptPointOptions ppo = new _AcEd.PromptPointOptions( "\nSpecify first corner:" ); _AcEd.PromptPointResult ppr = ed.GetPoint(ppo); if (ppr.Status != _AcEd.PromptStatus.OK) { return; } _AcGe.Point3d min = ppr.Value; _AcEd.PromptCornerOptions pco = new _AcEd.PromptCornerOptions( "\nSpecify opposite corner: ", ppr.Value ); ppr = ed.GetCorner(pco); if (ppr.Status != _AcEd.PromptStatus.OK) { return; } _AcGe.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 _AcGe.Point3d(min.X, min.Y, 0.0), new _AcGe.Point3d(max.X, max.Y, 0), new _AcGe.Point3d(), 1.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); }
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()); } }