CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

相关分类

循环访问字典条目

2023-1-1 03:28| 发布者: admin| 查看: 313| 评论: 0|来自: AutoCAD

字典的迭代器类是。下面的代码摘录从命名对象字典中获取字典 (ASDK_DICT)。然后,它使用字典迭代器单步执行字典条目并打印存储整数的值。最后,它删除迭代器并关闭字典。AcDbDictionaryIterator

void
iterateDictionary()
{
    AcDbDictionary *pNamedobj;
    acdbHostApplicationServices()->workingDatabase()
        ->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
    // Get a pointer to the ASDK_DICT dictionary.
    //
    AcDbDictionary *pDict;
    pNamedobj->getAt("ASDK_DICT", (AcDbObject*&)pDict,
        AcDb::kForRead);
    pNamedobj->close();
    // Get an iterator for the ASDK_DICT dictionary.
    //
    AcDbDictionaryIterator* pDictIter = pDict->newIterator();
    AsdkMyClass *pMyCl;
    Adesk::Int16 val;
    for (; !pDictIter->done(); pDictIter->next()) {
        // Get the current record, open it for read, and
        // print its data.
        //
        pDictIter->getObject((AcDbObject*&)pMyCl,
            AcDb::kForRead);
        pMyCl->getData(val);
        pMyCl->close();
        acutPrintf("\nintval is:  %d", val);
    }
    delete pDictIter;
    pDict->close();
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 15:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部