Hi!
I've just met an internal error in objectARX when I create a BTR and append entities to it. The BT successfully opened, BTR created, and AcDbLine entity is appended to the record, however when I want to append a "Revision Cloud" also to the BTR I get the INTERNAL ERROR !dbobji.cpp@387 message.
The revision cloud is created with acedCommand(RTSTR, L"_REVCLOUD", RTNONE); in a ON_CLICK event handle function. After the cloud is created I start to create the Block. I use acdbEntLast() function to get its ads_name, it's successfully got. After I can get the ObjectId from it without difficulty, and here I Open the entity as AcDbPolyline().
I can get its startPoint, change its Layer, but when I try to append it to the BlockReference all hope is gone:)
More attribute is also appeneded to the block without any problem.
I'm waiting for any suggestion, thank you.
Some code pieces:
BeginEditorCommand();
// Base point of Revision Cloud
bool bLoop = true;
acedInitDialog(true);
acedCommand(RTSTR, L"_REVCLOUD", RTNONE);
while(bLoop)
{
resbuf rb;
acedGetVar(L"cmdnames", &rb);
if(_tcsstr(_tcsupr(rb.resval.rstring), L"REVCLOUD") != NULL)
{
acedCommand(RTSTR, PAUSE, RTNONE);
}
else
{
bLoop = false;
}
free(rb.resval.rstring);
}
CompleteEditorCommand(FALSE);
// Create BlockRecord
AcDbBlockTableRecord *pBlockRecord = new AcDbBlockTableRecord;
pBlockRecord->setName(Name.c_str());
pBlockRecord->setOrigin(AcGePoint3d(0, 0, 0));
if((acErr = pBlockTable->add(pBlockRecord)) != Acad::eOk)
{
delete pBlockRecord;
pBlockTable->close();
return acErr;
}
pBlockTable->close();
// Get Entity
ads_name nmWolke;
if(acdbEntLast(nmWolke) != RTNORM)
{
...
return (Acad::eInvalidAdsName);
}
// Open Entity
AcDbPolyline *pWolke = new AcDbPolyline();
if((acErr = acdbOpenAcDbEntity((AcDbEntity *&)pWolke, eId, AcDb::kForWrite)) != Acad::eOk)
{
delete pWolke;
...
return acErr;
}
// Append
if((acErr = pBlockRecord->appendAcDbEntity(pWolke)) != Acad::eOk) // This is the BADGUY
{
delete pWolke;
....
return acErr;
}
Solved! Go to Solution.
Solved by owenwengerd. Go to Solution.
Your entity is already in the database, so it already belongs to a BTR. Instead of appendEntity(), you need to call AcDbBlockTableRecord::assumeOwnershipOf().
Thank you owenwengerd! The solution is so obvious as I read, but sure would have taken a lot of time to figure it out by my own. Thank you again;
Regards, István