.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible to change the saved xref path without reattaching the xref

1 REPLY 1
SOLVED
Reply
Message 1 of 2
RamanSBV
649 Views, 1 Reply

Is it possible to change the saved xref path without reattaching the xref

Hi,

 

Is it possible to change the saved xref path without reattaching the xref

 

Please guide me

 

Regards,

Raman

1 REPLY 1
Message 2 of 2
BrentBurgess1980
in reply to: RamanSBV

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

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost