The following code snippet shows how to change the path of all the Xrefs in a given drawing, to point to a new location. The code sample runs recursively to change the paths of the Xref even in the nested Xrefs. This code is useful in situations where the Xrefed drawings are being migrated from one folder/server to another folder/server. For complete VC++ ARX project download the attachment.
///////////////////////////////////////////////////////////// //Description: fGetXYPlane //1)Call this from ARX defined command ///////////////////////////////////////////////////////////// void fTest() { acutPrintf(_T("nTrying to change the paths of XREFs...")); //feel free to change the path as required fXrefRePath(_T("c:\test.dwg"),_T("c:\newlocation\")); } /////////////////////////////////////////////////////////////// //Description: fGetXYPlane //Parameters: //a)pDwgPath: Drawing name to repath the XREFs //b)pNewLocation: The new folder where the XREF are available //c)nDepth: Do not use. It specifies the nest level. It is //optional and is used while running recursively /////////////////////////////////////////////////////////////// void fXrefRePath(const TCHAR* pDwgPath, const TCHAR* pNewLocation,long nDepth) { //preparing the prefix TCHAR mPrefix[255]; if (1 < nDepth) { mPrefix[nDepth] = _T('