遍历字典条目
字典的迭代器类是 。以下代码摘录从命名对象字典中获取字典 (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(); } 父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 12:50
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.