块表浏览器执行getrecord后,插入实体失败
AcDbBlockTable *pBlockTable;acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord* pBlockTableRecord;
AcDbBlockTableIterator *pBlterator;
pBlockTable->newIterator(pBlterator);
pBlockTable->close();
//利用循环结构和块表浏览器遍历块表
addline();
for (pBlterator->start();!pBlterator->done();pBlterator->step())
{
pBlterator->getRecord(pBlockTableRecord,AcDb::kForRead);
}
delete pBlterator;
pBlterator = NULL;
pBlockTableRecord->close();
addline();
addline()是添加一条直线的代码,在第一次执行时,没有问题
最后一行再次执行报错,跟踪了一下,只读打开时地址有效,在写打开数据库时pBlockTableRecord地址失效,变成0X000000
发现是执行pBlterator->getRecord(pBlockTableRecord,AcDb::kForRead)的缘故,如果去掉这一句,就没有问题,各位大大,怎么回事呢?
for (pBlterator->start();!pBlterator->done();pBlterator->step())
{
//这里面已经打开了所有的表,遍历一个,关闭一个;
pBlterator->getRecord(pBlockTableRecord,AcDb::kForRead);
pBlockTableRecord->close();
}
页:
[1]