public void Ali2pro() { Alignment selectedAli = GetAlignment(); if (selectedAli != null) { ObjectIdCollection prfIds = selectedAli.GetProfileViewIds(); try { Boolean loopControl = true; while (loopControl) { foreach (ObjectId item in prfIds) { using (Transaction ts = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()) { PromptPointOptions pntOpt = new PromptPointOptions("\nSelect a point"); pntOpt.AllowNone = true; pntOpt.Message = "dogruSec"; PromptPointResult pnt = Ed.GetPoint("\nSelect the point"); if (pnt.Status != PromptStatus.OK) { return; } ; Double km = 0; Double ofset = 0; double x = 0; double y = 0; selectedAli.StationOffset(pnt.Value.X, pnt.Value.Y, ref km, ref ofset); ProfileView pv = ts.GetObject(item, OpenMode.ForRead) as ProfileView; pv.FindXYAtStationAndElevation(km, pv.Location.Y, ref x, ref y); Point3d p1 = new Point3d(x, pv.Location.Y, 0); Point3d p2 = new Point3d(x, pv.Location.Y + pv.ElevationMax, 0); Xline xl = new Xline(); xl.BasePoint = p1; xl.SecondPoint = p2; BlockTable acBlkTbl; acBlkTbl = ts.GetObject(Db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec; acBlkTblRec = ts.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; acBlkTblRec.AppendEntity(xl); ts.AddNewlyCreatedDBObject(xl, true); ts.Commit(); } } } } catch (System.Exception) { throw; } } }
public void Deneme() { Ed.PointMonitor += OnMouseMove; PromptPointOptions pOpt = new PromptPointOptions("helleo"); PromptPointResult pRes = Ed.GetPoint(pOpt); if (pRes.Status == PromptStatus.Cancel) { Ed.PointMonitor -= OnMouseMove; } }
public Point3d GetPoint() { PromptPointOptions opt = new PromptPointOptions("Noktayı seçiniz.."); PromptPointResult res = Ed.GetPoint(opt); if (res.Status == PromptStatus.OK) { Point3d pnt = new Point3d(res.Value.X, res.Value.Y, res.Value.Z); return(pnt); } else { Point3d pnt = new Point3d(0, 0, 0); return(pnt); } }
public void Point2Sec() { SampleLine smpLine = GetSampleLine(); SampleLineVertexCollection smpVertices = smpLine.Vertices; List <Point3d> pntList = new List <Point3d>(); Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline(); foreach (SampleLineVertex item in smpVertices) { pntList.Add(item.Location); } Line l = new Line(pntList[0], pntList[2]); ObjectIdCollection sectionViewID = smpLine.GetSectionViewIds(); Boolean loopControl = true; while (loopControl) { using (Transaction ts = Dwg.TransactionManager.StartTransaction()) { try { PromptPointResult pnt = Ed.GetPoint("\nSelect the point"); if (pnt.Status == PromptStatus.Cancel) { return; } Point3d pntOnSampleLine = l.GetClosestPointTo(pnt.Value, false); Double dist = Math.Sqrt(Math.Pow((pntList[0].X - pntOnSampleLine.X), 2) + Math.Pow(pntList[0].Y - pntOnSampleLine.Y, 2)); SectionView sectionView = ts.GetObject(sectionViewID[0], OpenMode.ForRead) as SectionView; Point3d pntOnSec = sectionView.Location; Double left = sectionView.OffsetLeft; Point3d startPoint = new Point3d(sectionView.Location.X + left, sectionView.Location.Y, sectionView.Location.Z); Point3d targetPoint = new Point3d(startPoint.X + dist, startPoint.Y, startPoint.Z); Point3d targetPoint2 = new Point3d(targetPoint.X, targetPoint.Y - 5, targetPoint.Z); Xline xl = new Xline(); xl.BasePoint = targetPoint; xl.SecondPoint = targetPoint2; AppendEntity(Db.BlockTableId, xl); ts.Commit(); } catch (System.Exception) { throw; } } } }