在代码中添加引用AcEditor.dll并使用AcEditor.Editor类的方法,以获取AcActDoc.Editor对象,如下所示:
using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Interop;
namespace Example { public class ExampleClass { public void ExampleMethod() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor editor = doc.Editor;
AcadApplication acadApp = (AcadApplication)Application.AcadApplication;
AcadDocument acadDoc = acadApp.ActiveDocument;
AcadModelSpace acadModelSpace = acadDoc.ModelSpace;
AcEditor.Editor acEditor = new AcEditor.Editor();
AcadEntity[] entities = acEditor.SelectAll();
foreach (AcadEntity entity in entities)
{
editor.WriteMessage("\nEntity Type: " + entity.EntityName);
}
}
}
}