You can use “Database.ReloadXrefs” API to reload the external referenced drawing files. “ReloadXrefs” takes a collection of object ids, which can be prepared by traversing through the block table as shown in below code.
[CommandMethod("ReloadXRefs")]
static public void ReloadXRefs()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
ObjectIdCollection ids = new ObjectIdCollection();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable table = tr.GetObject(db.BlockTableId,
OpenMode.ForRead) as BlockTable;
foreach (ObjectId id in table)
{
BlockTableRecord record = tr.GetObject(id,
OpenMode.ForRead) as BlockTableRecord;
if (record.IsFromExternalReference)
{
ids.Add(id);
}
}
tr.Commit();
}
//now relaod the xrefs
if (ids.Count != 0)
{
db.ReloadXrefs(ids);
}
}