Autodesk.AutoCAD.EditorInput.Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
PromptSelectionResult pkf = ed.SelectImplied();
if (pkf.Status != PromptStatus.OK) return;
ObjectId[] objIds = pkf.Value.GetObjectIds();
if (objIds.Length > 1)
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("\n请选择一个对象");
else
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
ObjectId id = objIds[0];
Entity ent = trans.GetObject(id, OpenMode.ForWrite) as Entity;
ent.ColorIndex = 1;
trans.Commit();
}
}
选择一个对象后,知道该对象的ObjectID,能获取该对象的一些属性吗?每次执行都出错在Entity ent = trans.GetObject(id, OpenMode.ForWrite) as Entity;这句话。希望大侠帮忙看看。不要因为太简单不理我哦