Hi,
I am trying to read the "region" in autocad drawing using realdwg, but i am getting the following error in reading the entity
"Access violation reading location 0xfcaf8008."
Code Used
*********************************************************************************************************************************************
int DWGMgr::eraseLayer()
{
AcDbBlockTable *pBlockTable;
if(Acad::eOk != m_pCurrentDatabase->getSymbolTable(pBlockTable, AcDb::kForRead))
{
return NS_FAIL;
}
AcDbBlockTableRecord *pBlockTableRecord;
if(Acad::eOk != pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForRead))
{
pBlockTable->close();
return NS_FAIL;
}
pBlockTable->close();
AcDbBlockTableRecordIterator *pBlkTblRcdItr;
pBlockTableRecord->newIterator(pBlkTblRcdItr);
AcDbObjectId pObjId;
for(pBlkTblRcdItr->start(); !pBlkTblRcdItr->done();pBlkTblRcdItr->step())
{
AcDbEntity* pEnt = NULL;
AcDbObject* ppObj = NULL;
Acad::ErrorStatus es ;
es = pBlkTblRcdItr->getEntityId(pObjId);
es = pBlkTblRcdItr->getEntity(pEnt,AcDb::kForWrite);
if(pEnt == NULL)
continue;
TCHAR* pszLayerName = pEnt->layer();
if(NSSTRCMP(pszLayerName, _T("ERRORS")) == 0)
{
pEnt->erase(true);
}
pEnt->close();
}
pBlockTableRecord->close();
delete pBlkTblRcdItr;
return NS_SUCCESS;
}
*********************************************************************************************************************************************
I don't understand your question. Does the displayed code cause an access violation? If so, which line of code?
I am getting the error when opening "region" for write
es = pBlkTblRcdItr->getEntity(pEnt,AcDb::kForWrite);
Thanks
Chockalingam
I guess you mean "AcDbRegion"? How do you know it's an AcDbRegion if the attempt to open fails? If you break on that exception, what is the call stack?
Yes i am mentioning about "AcDbRegion"
If i remove the "AcDbRegion" from my drawing then no error found, everything works fine
In the output window i get the following message
*********************************************************************************************************************************************
Object dump complete.
AcDb.dll Terminating!
acfirst.dll Terminating!
First-chance exception at 0x786836e3 in CADLoader.exe: 0xC0000005: Access violation reading location 0xfcba5b80.
Unhandled exception at 0x771515de in CADLoader.exe: 0xC0000005: Access violation reading location 0xfcba5b80.
*********************************************************************************************************************************************
You need to break on the exception and get the stack trace at the point of the exception.