Sample code:
void cmdHatch()
{
ads_name sset = { 0,0 };
AcDbObjectIdArray outsideIds; // IDs of outer curve(s)/region
AcDbObjectIdArray holeIds; // IDs of inner text(s)/pline(s)/region that shall create ONE hole.
acutPrintf(_T("\nSelect entities that form the outer conture: "));
if (acedSSGet(NULL, NULL, NULL, NULL, sset) == RTNORM)
{
outsideIds.setLogicalLength(0);
Selset2ObjIdArray(sset, outsideIds);
acedSSFree(sset);
}
else
return;
Acad::ErrorStatus es;
AcDbDatabase* db = acdbHostApplicationServices()->workingDatabase();
AcDbHatch* hatch = new AcDbHatch();
hatch->setDatabaseDefaults(db);
es = hatch->appendLoop(AcDbHatch::kExternal, outsideIds);
int stat = RTNORM;
while (stat==RTNORM)
{
acutPrintf(_T("\nSelect entities that form one inner hole: "));
stat = acedSSGet(NULL, NULL, NULL, NULL, sset);
if (stat == RTNORM)
{
holeIds.setLogicalLength(0);
Selset2ObjIdArray(sset, holeIds);
acedSSFree(sset);
es = hatch->appendLoop(AcDbHatch::kDefault, holeIds);
}
}
hatch->evaluateHatch();
postToDb(db, hatch);
}
long Selset2ObjIdArray(ads_name sset, AcDbObjectIdArray& objIdArr) {
Adesk::Int32 selSetLen = 0, i;
if (acedSSLength(sset, &selSetLen) != RTNORM)
return -1;
ads_name ename;
AcDbObjectId objId;
for (i = 0; i < selSetLen; i++) {
if (acedSSName(sset, i, ename) == RTNORM) {
if (acdbGetObjectId(objId, ename) == Acad::eOk)
objIdArr.append(objId);
}
}
return selSetLen;
}
Thomas Brammer ● Software Developer ● imos AG ● LinkedIn ● 
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.