The following code creates a group (pGroup) out of the line and circle created in the createLine() and createCircle() functions and puts the group into the GROUP dictionary. The object IDs of the line and circle are passed into the function. Notice how the GROUP dictionary is opened for writing, modified, and then explicitly closed.
void createGroup(AcDbObjectIdArray& objIds, char* pGroupName) { AcDbGroup *pGroup = new AcDbGroup(pGroupName); // Put the group in the group dictionary which resides // in the named object dictionary. // AcDbDictionary *pGroupDict; acdbHostApplicationServices()->workingDatabase() ->getGroupDictionary(pGroupDict, AcDb::kForWrite); AcDbObjectId pGroupId; pGroupDict->setAt(pGroupName, pGroup, pGroupId); pGroupDict->close(); // Now that the group has been added, it has an ObjectID. // This is important since the group will become a persistent // reactor for the added entities... for (int i = 0; i < objIds.length(); i++) { pGroup->append(objIds[i]); } pGroup->close(); }