Message 1 of 8
INSERT fails on custom entity derived from AcDbBlockReference

Not applicable
04-18-2006
09:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a custom entity derived from AcDbBlockReference. I have created a drawing containing one or more of these custom entites and I want to insert that drawing into another drawing. Of course, since the block to which the custom entity is reference is required in the second drawing also, I have ensured that all the relevant blocks are available.
However, if I run the INSERT command and select the first drawing, it is consistently throwing up an "eWrongDatabase" error for each custom entity in the drawing. This error appears in the following code:
Acad::ErrorStatus CMyCustomEntity::setRefBlock(const char* pszRefBlock)
{
// Ensure that we are open for writing
assertWriteEnabled();
// Get the block id of the given name
Acad::ErrorStatus es;
AcDbBlockTable *pBT;
es = acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT, AcDb::kForRead);
// Get the referenced block
AcDbObjectId objRefId;
es = pBT->getAt(m_pszRefBlock, objRefId);
// If it was not found, this is a serious error
if (es != Acad::eOk)
{
// Close the block table
pBT->close();
// Erase this equipment from the drawing
erase();
// Return the error status for further processing
return es;
}
// Close the block table
pBT->close();
// Set the reference to the block ID
if ((es = setBlockTableRecord(objRefId)) != Acad::eOk)
{
// --------------- This is the error that is appearing ---------------------
acutPrintf("\nError %d setting block reference to '%s'.\n", es, m_pszRefBlock);
erase();
return es;
}
// More code here
...
...
...
}
I have tried the objRefId.convertToRedirectedId() before calling setBlockTableRecord() but the error still persists. I should note here that this functionality was working perfectly in AutoCAD 2000/2002, but it is failing in AutoCAD 2006.
However, if I run the INSERT command and select the first drawing, it is consistently throwing up an "eWrongDatabase" error for each custom entity in the drawing. This error appears in the following code:
Acad::ErrorStatus CMyCustomEntity::setRefBlock(const char* pszRefBlock)
{
// Ensure that we are open for writing
assertWriteEnabled();
// Get the block id of the given name
Acad::ErrorStatus es;
AcDbBlockTable *pBT;
es = acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT, AcDb::kForRead);
// Get the referenced block
AcDbObjectId objRefId;
es = pBT->getAt(m_pszRefBlock, objRefId);
// If it was not found, this is a serious error
if (es != Acad::eOk)
{
// Close the block table
pBT->close();
// Erase this equipment from the drawing
erase();
// Return the error status for further processing
return es;
}
// Close the block table
pBT->close();
// Set the reference to the block ID
if ((es = setBlockTableRecord(objRefId)) != Acad::eOk)
{
// --------------- This is the error that is appearing ---------------------
acutPrintf("\nError %d setting block reference to '%s'.\n", es, m_pszRefBlock);
erase();
return es;
}
// More code here
...
...
...
}
I have tried the objRefId.convertToRedirectedId() before calling setBlockTableRecord() but the error still persists. I should note here that this functionality was working perfectly in AutoCAD 2000/2002, but it is failing in AutoCAD 2006.