You might wonder, when an entity is hatched, is there is an associative entity created that is the hatch (an AcDbHatch)? And how do I locate this object?
The way the hatch responds to changes in the entity is through notification. The hatch is actually made a persistent reactor of the entity in the hatch. You can then obtain the hatch entity in this way. The following code sample demonstrates this:
void getHatchEntity()
{
ads_name eName;
ads_point pt;
if( RTNORM != acedEntSel(_T("\nSelect the entity"), eName, pt ) )
return;
AcDbObjectId id;
acdbGetObjectId( id, eName );
AcDbEntity* pEnt;
acdbOpenObject(pEnt, id, AcDb::kForRead );
if( pEnt == NULL )
return;
AcDbHatch* pHatch = NULL;
AcDbVoidPtrArray* pReactors = pEnt->reactors();
for( int i=0; pHatch == NULL &&
i<pReactors->length(); i++ ) {
if( acdbIsPersistentReactor( pReactors->at(i) )) {
AcDbObjectId id =
acdbPersistentReactorObjectId( pReactors->at(i));
acdbOpenObject(pHatch, id, AcDb::kForRead );
}
}
if( pHatch != NULL ) {
pHatch->highlight();
pHatch->close();
}
pEnt->close();
}