//[CommandMethod("UnlodeExteralReference")]
public void UnlodeExteralReference(string btrName)
{
Database db=HostApplicationServices.WorkingDatabase;
using(Transaction trans=db.TransactionManager.StartTransaction())
{
//打开块表
BlockTable bt=trans.GetObject(db.BlockTableId,OpenMode.ForRead) as BlockTable;
foreach(ObjectId id in bt)
{
//遍历块表
BlockTableRecord btr=Trans.GetObject(id,OpenMode.ForRead) as BlockTableRecord;
if(btr.IsFromExternalReference && btr.name==btrName)
{
db.UnlodeXrefs(new ObjectIdCollection(){id});
break;
}
}
trans.Commit();
}
}