Community
Hi,
Is it possible to change the saved xref path without reattaching the xref
Please guide me
Regards,
Raman
Solved! Go to Solution.
Solved by BrentBurgess1980. Go to Solution.
Try this - I haven' tested it yet though.
public static void Repath(Database db, string xrefName, string newPath) { if (string.IsNullOrEmpty(newPath)) { throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.FileNotFound, "The path can not be found"); } if (!File.Exists(newPath)) { throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.FileNotFound, "The file can not be found"); } BlockTableRecord btr = default(BlockTableRecord); using (Transaction tr = db.TransactionManager.StartTransaction()) { XrefGraph DbXrGraph = db.GetHostDwgXrefGraph(true); XrefGraphNode XrGraphNode = null; XrGraphNode = DbXrGraph.GetXrefNode(xrefName); btr = (BlockTableRecord)tr.GetObject(XrGraphNode.BlockTableRecordId, OpenMode.ForWrite); btr.PathName = newPath; tr.Commit(); } }