Modifying geometry in blocks

Hi-
Is there a way to modify an objects geometry while it is inside a block definition? I’m trying to clear the NGon list of meshes before they are exported. So far I have:

filt = Rhino.DocObjects.ObjectType.InstanceReference
 rc, object = Rhino.Input.RhinoGet.GetOneObject('Get Block', True, filt)
 if rc == Rhino.Commands.Result.Success:
     blockInstance = object.Object()
     blockObjs = blockInstance.InstanceDefinition.GetObjects()
     for rhObj in blockObjs:
         if rhObj.Geometry.ObjectType == Rhino.DocObjects.ObjectType.Mesh:
             nGons = rhObj.MeshGeometry.Ngons
             if len(nGons) > 0:
                 print 'NGons Found: ' + str(rhObj.Id)
                 nGons.Clear()
                 rhObj.CommitChanges()

Is there any way to get this to work or do I have to modify the mesh outside the block and then add it to instance definition.

Any help would be greatly appreciated!

Did you try ?
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_InstanceDefinitionTable_ModifyGeometry_2.htm

i would guess, that your get a kind of shallow-duplicate with this line
nGons = rhObj.MeshGeometry.Ngons
and that is described here
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_GeometryBase_DuplicateShallow.htm
this would mean - but it is a guess: as soon as you modify the geometry, the connection to the initial DocObject is lost.

for standard Geometry-DocObjects in c# Replace is used to update the geometry:
doc.Objects.Replace(objref, newGeometry);
doc.Views.Redraw();
so i thinked the function linked above is the corresponding approach for instance-definitions…

hope that helps - kind regards -tom