曲线救国,这个法子好像可以: Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Transaction trans = db.TransactionManager.StartTransaction(); PromptSelectionOptions Opts = new PromptSelectionOptions(); PromptSelectionResult res = ed.GetSelection(Opts); Polyline plineSelected = new Polyline(); if (res.Status != PromptStatus.OK) { ed.WriteMessage("您所选的不是PLINE线实体!"); trans.Commit(); trans.Dispose(); return; } Autodesk.AutoCAD.EditorInput.SelectionSet SS = res.Value; ObjectId plid = SS.GetObjectIds()[0];//获取所选Pline线的ID Entity ent = (Entity)trans.GetObject(plid, OpenMode.ForRead, false); if (ent.GetType() == typeof(Polyline)) { plineSelected = (Polyline)ent; } double dtemp = plineSelected.StartPoint.X; trans.Commit(); trans.Dispose(); |