马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
http://adndevblog.typepad.com/autocad/2012/06/reloading-external-reference-through-net.html
Reloading external reference through .NETBy Virupaksha Aithal
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);
- }
- }
|