private bool getPoint(string prompt, _Ge.Point3d ptBase, ref _Ge.Point3d pt, ref bool finish) { _Ed.PromptPointOptions pPtOpts = new _Ed.PromptPointOptions(""); pPtOpts.Keywords.Add("F"); pPtOpts.Message = prompt; pPtOpts.UseBasePoint = true; pPtOpts.BasePoint = ptBase; _Ed.PromptPointResult pPtRes; pPtRes = _c.ed.GetPoint(pPtOpts); if (pPtRes.Status == _Ed.PromptStatus.Keyword) { _Ed.PromptPointOptions lastPtOpts = new _Ed.PromptPointOptions(""); pPtOpts.Message = "Last Point"; pPtOpts.UseBasePoint = true; pPtOpts.BasePoint = ptBase; pPtRes = _c.ed.GetPoint(lastPtOpts); pt = pPtRes.Value; finish = true; } else if (pPtRes.Status == _Ed.PromptStatus.OK) { pt = pPtRes.Value; } else if (pPtRes.Status == _Ed.PromptStatus.Cancel) { return(false); } return(true); }
private _Ge.Point3d getPoint() { _Ed.PromptPointOptions pPtOpts = new _Ed.PromptPointOptions("Select output location: "); _Ed.PromptPointResult pPtRes = _c.ed.GetPoint(pPtOpts); if (pPtRes.Status != _Ed.PromptStatus.OK) { throw new DMTException("[ERROR] cancelled"); } return(pPtRes.Value); }
private G.Point getBendingInsertionPoint() { _Ed.PromptPointOptions pickedPointOptions = new _Ed.PromptPointOptions("\nSelect Bending insertion point"); _Ed.PromptPointResult pickedPoint = _c.doc.Editor.GetPoint(pickedPointOptions); if (pickedPoint.Status != _Ed.PromptStatus.OK) { throw new DMTException("[ERROR] Bending insertion point - cancelled"); } _Ge.Point3d pt = pickedPoint.Value; G.Point picked = new G.Point(pt.X, pt.Y); return(picked); }
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(); }
public static AcGe.Point3d GetLocationRaster() { AcEd.PromptPointResult pPtRes; AcEd.PromptPointOptions pPtOpts = new AcEd.PromptPointOptions("*-*-") { Message = "\nВкажіть місце вставки растру: " }; pPtRes = CurrentCAD.Editor.GetPoint(pPtOpts); if (pPtRes.Status == AcEd.PromptStatus.OK) { return(pPtRes.Value); } return(AcGe.Point3d.Origin); }
private bool getInitPoint(string prompt, ref _Ge.Point3d pt) { _Ed.PromptPointOptions pPtOpts = new _Ed.PromptPointOptions(""); pPtOpts.Message = prompt; pPtOpts.UseBasePoint = false; _Ed.PromptPointResult pPtRes; pPtRes = _c.ed.GetPoint(pPtOpts); pt = pPtRes.Value; if (pPtRes.Status == _Ed.PromptStatus.Cancel) { return(false); } return(true); }
//[AcTrx.CommandMethod("Land_InsertBlocksAlongLine")] public static void InsertBlocksAlongLine() { AcEd.PromptPointOptions ppo = new AcEd.PromptPointOptions("Вкажіть першу точку:"); AcEd.PromptPointResult ppr = CurrentCAD.Editor.GetPoint(ppo); if (ppr.Status == AcEd.PromptStatus.OK) { AcGe.Point3d startPoint = ppr.Value; ArraysBlocks arrBlock = new ArraysBlocks("11", 1, 0, startPoint); ppo.Message = "Вкажіть напрямок:"; ppo.UseBasePoint = true; ppo.BasePoint = startPoint; ppr = CurrentCAD.Editor.GetPoint(ppo); AcGe.Point3d dirPoint = ppr.Value; arrBlock.DisplayAlongLine(dirPoint, 0, 50, 100); } }
private bool getPositionPoint(string prompt, _Ge.Point3d ptStart, _Ge.Point3d ptEnd, ref _Ge.Point3d ptPos, ref double rotation) { _Ge.Point3d ptBase = new _Ge.Point3d((ptEnd.X + ptStart.X) / 2, (ptEnd.Y + ptStart.Y) / 2, (ptEnd.Z + ptStart.Z) / 2); _Ed.PromptPointOptions pPtOpts = new _Ed.PromptPointOptions(""); pPtOpts.Message = prompt; pPtOpts.UseBasePoint = true; pPtOpts.BasePoint = ptBase; _Ed.PromptPointResult pPtRes; pPtRes = _c.ed.GetPoint(pPtOpts); _Ge.Point3d temp = pPtRes.Value; if (pPtRes.Status == _Ed.PromptStatus.Cancel) { return(false); } double dX = temp.X - ptBase.X; double dY = temp.Y - ptBase.Y; if (Math.Abs(dX) > Math.Abs(dY)) { rotation = Math.PI / 2; double newX = temp.X; double newY = ptStart.Y; ptPos = new _Ge.Point3d(newX, newY, ptStart.Z); } else { rotation = 0.0; double newX = ptStart.X; double newY = temp.Y; ptPos = new _Ge.Point3d(newX, newY, ptStart.Z); } return(true); }
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()); } }