|
[code]bool isDynamicBlock(const AcDbObjectId &objId)
{
AcDbObject *pObj;
AcDbBlockReference *pBref;
AcDbBlockTableRecord *pBTR;
Acad::ErrorStatus es;
AcDbObjectId blockTableRecordId;
bool bIsDynamic = false;
// Is objId a BREF or a BTR?
es = acdbOpenObject(pObj, objId, AcDb::kForRead);
if (es==Acad::eOk)
{
if (pBref = AcDbBlockReference::cast(pObj))
{
blockTableRecordId = pBref->blockTableRecord();
AcDbDynBlockReference dynBlockRef(pBref);
// dynBlockRef.isDynamicBlock(); is not enough!
// Only returns true for direct BREF to the dynamic source-block!
AcDbObjectId dynBTRid = dynBlockRef.dynamicBlockTableRecord();
if (!dynBTRid.isNull())
bIsDynamic = AcDbDynBlockReference::isDynamicBlock(dynBTRid);
}
else if (pBTR = AcDbBlockTableRecord::cast(pObj))
{
blockTableRecordId = objId;
}
pObj->close();
if (!bIsDynamic)
bIsDynamic = AcDbDynBlockReference::isDynamicBlock(blockTableRecordId);
}
return bIsDynamic;
}[/code]Blocktablerecord size |
|