LoveArx 发表于 2016-8-16 16:00:02

将指定图层的内容输出到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 *****

zjy2999 发表于 2016-8-19 17:36:51

谢谢,新人学习!!!!!

白杨恒毅 发表于 2016-8-20 11:09:30

谢谢,新人学习!!!!!

shuaier 发表于 2016-9-5 22:09:49

测试下看看!

用途 发表于 2016-9-23 15:52:20

学习学习,支持楼主。。。。

war5566sakura 发表于 2016-10-13 12:32:01

來看看 學習

q1355188058 发表于 2016-11-28 17:25:18

确实是难得好帖啊,顶先{:1_23:}{:1_20:}

km930324 发表于 2017-6-2 09:42:27

新人学习,谢谢啦~

mqqqq 发表于 2018-3-19 20:26:32

谢谢分享!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

xinxirong 发表于 2018-3-20 12:27:19

感谢楼主的程序!这个相当实用

宏光 发表于 2018-7-26 22:37:30

谢谢 学习了

1121443108qaz 发表于 2018-9-7 15:28:10

看看看看看看

松s_king 发表于 2018-11-13 10:01:22

回复学习一下

819534890 发表于 2018-11-13 12:49:55

回复学习,谢谢

xyz135792 发表于 2018-12-7 15:37:28


谢谢,新人学习!!!!!
页: [1] 2 3
查看完整版本: 将指定图层的内容输出到DXF文件