绘制实体时发生eAlreadyInDb异常,求教
首先读取一个dwg文件中的实体到List<Entity>集合,再将其添加到当前模型空间,但是提示eAlreadyInDb,求教各位大神 Database db = HostApplicationServices.WorkingDatabase;List<Entity> entities = ReadIn("D://sourcefiles//zz2.dwg");
ObjectId entityId = ObjectId.Null;
//插入对象
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord modelSpace = (BlockTableRecord)trans.GetObject(bt, OpenMode.ForWrite);
foreach(Entity entity in entities)
{
entityId = modelSpace.AppendEntity(entity);// ------ ----eAlreadyInDb异常
trans.AddNewlyCreatedDBObject(entity, true);
}
trans.Commit();
} eAlreadyInDb,实体已经在别的Db里了 你偏要再加到其他Db,,,
你这种情况,用Clone或者WblockCloneObjects
页:
[1]