创建一个浏览器(iterator),用于遍历线型表中的符号表记录。
步骤:
-
首先以读操作模式打开线型表;
-
之后创建一个新的浏览器;
-
然后创建一个指向线型表的指针;
-
在for循环中使用浏览器函数遍历线性表记录,得到每条记录的线型名;
-
在退出for循环后,我们就删除浏览器,并关闭线型表。
实现源代码:
static void aaaMyGroupMyCommand () { AcDbDatabase *pCurDb; AcDbLinetypeTable *pLinetypeTbl; pCurDb = acdbHostApplicationServices()->workingDatabase(); pCurDb->getLinetypeTable(pLinetypeTbl, AcDb::kForRead); //Create a new iterator that starts at table //beginning and skips deleted. AcDbLinetypeTableIterator *pLtIterator; pLinetypeTbl->newIterator(pLtIterator); //Walk the table getting every table record and //printing the linetype name. // AcDbLinetypeTableRecord *pLtTableRcd; ACHAR *pLtName; for (; !pLtIterator->done(); pLtIterator->step()) { pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead); pLtTableRcd->getName(pLtName); pLtTableRcd->close(); acutPrintf(_T("\nLinetype name is: %s"), pLtName); free(pLtName); } delete pLtIterator; pLinetypeTbl->close(); }
效果:
在AutoCAD2018命令行输命令:MyCommandLocal,显示: