Hi,
I am attaching a File as a xRef. At the time of Attachment, I select attach as attachment, and No Path in Path.
Now if I try to fetch detail of this file using MdiActiveDocument.Database and BlockTableRecord, I gets only file name not the path. However, In AutoCAD we can see the file path under "Found At". Can we read / fetch this using C#.
In cas of Full Path or relative Path, I gets full path in btr.PathName
Kindly reply back ASAP. here is my code and I am using AutoCAD 2013
Database db = acadApp.DocumentManager.MdiActiveDocument.Database;
using (Transaction Trans = db.TransactionManager.StartTransaction())
{
BlockTable BlkTbl = (BlockTable)Trans.GetObject(db.BlockTableId, OpenMode.ForRead,false,true);
db.ResolveXrefs(false, false);
XrefGraph XrGph = db.GetHostDwgXrefGraph(true);
XrefArray = new MyXrefInfo[XrGph.NumNodes - 1]; //A Strucuture Array for all xRef;
for (int i = 1; i < XrGph.NumNodes; i++)
{
XrefGraphNode XrNode = XrGph.GetXrefNode(i);
BlockTableRecord btr = (BlockTableRecord)Trans.GetObject(XrNode.BlockTableRecordId, OpenMode.ForRead);
MyXrefInfo XrInfo = new MyXrefInfo(); //A Strucuture object for each xRef;
XrInfo.Name = XrNode.Name;
XrInfo.Path = btr.PathName;
XrInfo.DrawingPath = db.Filename;
XrefArray[i - 1] = XrInfo;
}
}
If you don't provide a path, the library path is searched. You can search the library path using HostApplicationServices.Current.FindFile().