zoukankan      html  css  js  c++  java
  • objectARX 获取指定图层上所有实体ID

    2015-12-17

     1 //获取指定图层上所有实体ID
     2 AcDbObjectIdArray GetAllEntityId(const TCHAR* layername)
     3 {
     4     AcDbObjectIdArray entIds;
     5     bool bFilterlayer = false;
     6     AcDbObjectId layerId;
     7     //获取指定图层对象ID
     8     if (layername != NULL)
     9     {
    10         AcDbLayerTable *pLayerTbl = NULL;
    11         acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTbl, AcDb::kForRead);
    12         if (!pLayerTbl->has(layername))
    13         {
    14             pLayerTbl->close();
    15             return entIds;
    16         }
    17         pLayerTbl->getAt(layername, layerId);
    18         pLayerTbl->close();
    19         bFilterlayer = true;
    20     }
    21     //获得块表
    22     AcDbBlockTable *pBlkTbl = NULL;
    23     acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlkTbl, AcDb::kForRead);
    24     //块表记录
    25     AcDbBlockTableRecord *pBlkTblRcd = NULL;
    26     pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead);
    27     pBlkTbl->close();
    28     //创建遍历器,依次访问模型空间中的每一个实体
    29     AcDbBlockTableRecordIterator *it = NULL;
    30     pBlkTblRcd->newIterator(it);
    31     for (it->start(); !it->done(); it->step())
    32     {
    33         AcDbEntity *pEnt = NULL;
    34         Acad::ErrorStatus es = it->getEntity(pEnt, AcDb::kForRead);
    35         if (es == Acad::eOk)
    36         {
    37             if (bFilterlayer)//过滤图层
    38             {
    39                 if (pEnt->layerId() == layerId)
    40                 {
    41                     entIds.append(pEnt->objectId());
    42                 }
    43             }
    44             else
    45             {
    46             //    entIds.append(pEnt->objectId());
    47                 pEnt->close();
    48             }
    49         }
    50     }
    51     delete it;
    52     pBlkTblRcd->close();
    53     return entIds;
    54 }
  • 相关阅读:
    数据仓库 VS 数据库
    准确率,精确率,召回率,F-measure 之间的关系
    OpenCV——查找、绘制轮廓
    OpenCV——仿射变换
    OpenCV函数 重映射
    Hough变换原理
    霍夫变换(直线检测、圆检测)
    边缘检测算子+滤波总结
    图像滤波—opencv函数
    图像滤波
  • 原文地址:https://www.cnblogs.com/nightnine/p/5053375.html
Copyright © 2011-2022 走看看