Adding elements to an existing Rhino Group C++


I have a group id of an object:

How can I add additional objects to this group when I know group index?

This should work:

static bool RhinoAddObjectToGroup(
  const CRhinoObject* pObject, 
  int group_index
  if (nullptr == pObject 
    || group_index < 0
    return false;

  CRhinoDoc* pDoc = pObject->Document();
  if (nullptr == pDoc 
    || group_index >= pDoc->m_group_table.GroupCount()
    || pObject->Attributes().IsInGroup(group_index)
    return false;

  CRhinoObjectAttributes attributes = pObject->Attributes();
  return pDoc->ModifyObjectAttributes(CRhinoObjRef(pObject), attributes);

– Dale