How to apply MoveGrid() changes to surface

Hi everyone!
I followed the steps described in http://wiki.mcneel.com/developer/sdksamples/movegrips to modify an existing surface locally in a cage. I think the only difference is, that I automatically pick up the Grip-Points. Before running my Command I execute _CageEdit select the surface -> Enter -> Select a Existing Cage -> Choose Local -> type 1 -> I can see the Grip Point and move them manually.

After the Command(please see Source Code) I see a perfect preview (yellow lines) of the result but I have no idea how accept/apply this preview. In the moment I press Esc every change is lost :frowning:

Thank you in advance!

CRhinoCommand::result CCommandRhinoFFDC::RunCommand( const CRhinoCommandContext& context )
{
CRhinoObjectIterator it(CRhinoObjectIterator::undeleted_objects, CRhinoObjectIterator::active_and_reference_objects);
it.IncludeLights( false );
it.IncludeGrips( true );
int count = 0;
CRhinoObjectGrips* test;
CRhinoXformObjectList xform_list;

for( CRhinoObject* pObject = it.First(); pObject; pObject = it.Next() )
{
if (pObject->ObjectType() == ON::grip_object)
{
xform_list.AddObject(pObject, true);
}
}

int i;

for(i=0;i<27;i++)
{
CRhinoGripObject* ttt = xform_list.m_grips[i];
if(ttt->m_base_point.x>152)
{
ON_3dPoint newpoint;
newpoint.Set(170.0000000,ttt->m_base_point.y,ttt->m_base_point.z);
ttt->MoveGrip(newpoint);
}

}

for( i = 0; i < xform_list.m_grip_owners.Count(); i++ )
{
CRhinoObject* old_object = xform_list.m_grip_owners[i];
if( old_object )
{
CRhinoObject* new_object = old_object->m_grips->NewObject();
if( new_object )
context.m_doc.ReplaceObject( CRhinoObjRef(old_object), new_object, true );
}
}

context.m_doc.Redraw();

return CRhinoCommand::success;
}

Does this sample help?

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleMoveGrips.cpp