将指定图层的内容输出到DXF文件
How to export specific layers to a dxf file using ObjectARX?Q:
I want to export some specific layers to a .DXF file. AcDbDatabase::dxfOut() can export a drawing, but I only want to export specific layers. How can I do this using ObjectARX?
A:
To make a DXF file that contains entities from specified layers, use acedSSGet() with a filter to select the entities on the required layers. Then wblock these entities to a new database and call dxfOut() to create the dxf file. Below is one of the functions from the attached example. The function named FilterObjects (not shown here) fills a selectionSet with the entities on layer 0 and a layer named "Layer1".
-
int FilterObjects(ads_name ss)
{
int resVal;
char *chLayerName[] = {"0", "Layer1"};
struct resbuf * resBufLayerFilter = NULL;
struct resbuf **resBufTemp;
resBufTemp = &resBufLayerFilter;
*resBufTemp = acutBuildList(-4, "<OR", 0);
resBufTemp = &(*resBufTemp)->rbnext;
for (int nIndex = 0 ; nIndex<2;nIndex++)
{
*resBufTemp = acutBuildList (8, chLayerName, 0);
resBufTemp = &(*resBufTemp)->rbnext;
}
*resBufTemp = acutBuildList(-4, "OR>", 0);
resBufTemp = &(*resBufTemp)->rbnext;
while(true)
{
//select all objects only on layer '0, Layer1'
resVal = acedSSGet(L"_X", NULL, NULL, resBufLayerFilter, ss);
if (resVal == RTCAN || resVal == RTERROR)
{
//user selected zero objects
if (resVal == RTERROR)
acutPrintf (L"\nZero objects are selected.\n");
acutRelRb(resBufLayerFilter);
return resVal;
}
else
break;
}
acutRelRb(resBufLayerFilter);
return resVal;
}
下面是测试命令
**** Hidden Message *****
谢谢,新人学习!!!!!
谢谢,新人学习!!!!! 测试下看看!
学习学习,支持楼主。。。。
來看看 學習 确实是难得好帖啊,顶先{:1_23:}{:1_20:} 新人学习,谢谢啦~ 谢谢分享!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
感谢楼主的程序!这个相当实用 谢谢 学习了 看看看看看看 回复学习一下 回复学习,谢谢
谢谢,新人学习!!!!!