Community
Hi,
XRefs are accessed in RealDWG the exact same way than in AutoCAD. You first need to call "Database.ResolveXrefs" and of course to have those referenced documents physically present on your disk. They won't get resolved otherwise...
Here is an AutoCAD command. RealDWG code will be the same, except you don't have Document, Editor and you get the database using HostApplicationServices.WorkingDatabase:
[CommandMethod("XrefGraph")] public static void XrefGraph() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction Tx = db.TransactionManager.StartTransaction()) { db.ResolveXrefs(true, false); XrefGraph xg = db.GetHostDwgXrefGraph(true); for (int i = 1; i < xg.NumNodes; ++i) { XrefGraphNode node = xg.GetXrefNode(i); if (node.XrefStatus == XrefStatus.Resolved) { BlockTableRecord btr = Tx.GetObject(node.BlockTableRecordId, OpenMode.ForRead) as BlockTableRecord; ed.WriteMessage("\n---------------------"); if (btr.IsFromExternalReference == true) { ed.WriteMessage("\nXref path name: " + btr.PathName); } ed.WriteMessage("\nName of Xref (Found name): " + node.Database.Filename); } } } }
Philippe Leefsma
Developer Consultant
Developer Technical Services
Global Subscription & Support