Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can RealDWG 2013 read Xref file path?

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
227 Views, 0 Replies

Can RealDWG 2013 read Xref file path?

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();
}

 

Tags (1)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost