I want to use RealDWG 2013 read a dwg file and get the Xref path, but It seems not work by using ReadDwfFile().
can RealDWG use other method to read the dwg file and get the Xref path?
Here is my code:
string dwgFilePath = "C:\abc.dwg";
Database db = new Database(false, true);
db.ReadDwgFile(dwgFilePath, FileShare.Read, false, String.Empty);
HostApplicationServices.WorkingDatabase = db;
using(Transaction trans = db.TransactionManager.StartTransaction()){
ObjectId acBlkTlbId = db.BlockTableId;
BlockTable acBlkTlb = trans.GetObject(acBlkTlbId, OpenMode.ForRead) as BlockTable;
foreach (ObjectId objecId in acBlkTlb) {
BlockTableRecord btr = trans.GetObject(objecId, OpenMode.ForRead) as BlockTableRecord;
if(btr.XrefStatus == XrefStatus.NotAnXref){
foreach (ObjectId objId in btr) {
RXClass xObjectClass = objId.GetObject(OpenMode.ForRead).GetRXClass();
if (xObjectClass.Name == "AcDbRasterImage") {
RasterImage xImage = trans.GetObject((ObjectId)objId, OpenMode.ForRead) as RasterImage;
return xImage.Path;
}
}
}
}
trans.Commit();
}