zoukankan      html  css  js  c++  java
  • ObjectArx学习笔记-获取某一图层上所有直线


    //-----------------------------------------------------------------------------
    //----- acrxEntryPoint.h
    //-----------------------------------------------------------------------------
    #include "StdAfx.h"
    #include "resource.h"
    #include "dbsymtb.h"

    //-----------------------------------------------------------------------------
    #define szRDS _RXST("qxzy")

    //-----------------------------------------------------------------------------
    //----- ObjectARX EntryPoint
    class CGetEntsOnLayerApp : public AcRxArxApp {

    public:
    CGetEntsOnLayerApp () : AcRxArxApp () {}

    virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
    // TODO: Load dependencies here

    // You *must* call On_kInitAppMsg here
    AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;

    // TODO: Add your initialization code here

    return (retCode) ;
    }

    virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
    // TODO: Add your code here

    // You *must* call On_kUnloadAppMsg here
    AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

    // TODO: Unload dependencies here

    return (retCode) ;
    }

    virtual void RegisterServerComponents () {
    }

    public:

    // - qxzyGetEntsOnLayer._GetEntsOnLayer command (do not rename)
    static void qxzyGetEntsOnLayer_GetEntsOnLayer(void)
    {
    // Add your code for command qxzyGetEntsOnLayer._GetEntsOnLayer here
    AcDbLayerTable *pLayerTbl;
    acdbHostApplicationServices()->workingDatabase()
    ->getSymbolTable(pLayerTbl,AcDb::kForRead);
    if(!pLayerTbl->has(_T("测试")))
    {
    acutPrintf(_T(" 当前图形中未包含"测试"图层!"));
    pLayerTbl->close();
    return;
    }

    AcDbObjectId layerId;
    pLayerTbl->getAt(_T("测试"),layerId);
    pLayerTbl->close();

    AcDbBlockTable *pBlkTbl;
    acdbHostApplicationServices()->workingDatabase()
    ->getBlockTable(pBlkTbl, AcDb::kForRead);

    AcDbBlockTableRecord *pBlkTblRcd;
    pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead);
    pBlkTbl->close();

    AcDbBlockTableRecordIterator *pltr;
    pBlkTblRcd->newIterator(pltr);

    AcDbEntity *pEnt;
    for(pltr->start();!pltr->done();pltr->step())
    {
    pltr->getEntity(pEnt, AcDb::kForWrite);

    if(pEnt->layerId() == layerId)
    {
    //whether it's a line
    AcDbLine *pLine = AcDbLine::cast(pEnt);
    if(pLine != NULL);
    {
    pLine->setColorIndex(1);
    }
    }

    pEnt->close();
    }
    delete pltr;
    pBlkTblRcd->close();

    }
    } ;

    //-----------------------------------------------------------------------------
    IMPLEMENT_ARX_ENTRYPOINT(CGetEntsOnLayerApp)

    ACED_ARXCOMMAND_ENTRY_AUTO(CGetEntsOnLayerApp, qxzyGetEntsOnLayer, _GetEntsOnLayer, GetEntsOnLayer, ACRX_CMD_TRANSPARENT, NULL)

  • 相关阅读:
    SqlServer为字段创建索引
    学习java时在要求输出的数字带俩个小数点时,利用String.format时出现的问题
    JAVA字符串格式化-String.format()的使用
    Java中使用JSONTokener判断接口返回字符串是JSONObject还是JSONArray
    StringUtils工具类中的isBlank()方法和isEmpty()方法的区别
    Idea 隐藏不必要的文件或文件夹 eg:(.idea,.gitignore,*.iml)
    使用Gradle构建android应用
    Android开源库--SlidingMenu左右侧滑菜单
    cmd.exe-应用程序错误 应用程序无法正常启动(0xc0000142)
    Cocos2d-x 开发手记
  • 原文地址:https://www.cnblogs.com/mjgw/p/12392659.html
Copyright © 2011-2022 走看看