[每日一码] 如何修改图形中XREF路径(包括嵌套)
问题:如何修改图形中XREF路径(包括嵌套)?
How to change the path of Xref (including the nested ones) in a drawing?
解决方案:
下面代码段演示来如何修改图形中XREFS的路径指向一个新的位置。对于嵌套的XREFS,代码递归运行改变路径。这个代码适合把XREFS文件从一个目录改变到另外的目录时候使用。
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.
普通浏览复制代码
// TODO: Here you can add your own includes / declarations
#include "acedxref.h"
void fTest();
void fXrefRePath(const char* pDwgPath,const char* pNewLocation,long mnDepth = 1);
///////////////////////////////////////////////////////////////////////////////////////////////
//Description: fGetXYPlane
//1)Call this from ARX defined command
///////////////////////////////////////////////////////////////////////////////////////////////
void fTest()
{
acutPrintf(采用T("\nTrying to change the paths of XREFs..."));
fXrefRePath(采用T("c:\\test.dwg"),采用T("c:\\newlocation\\")); //feel free to change the path as required
}
///////////////////////////////////////////////////////////////////////////////////////////////
//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;
页:
[1]