Modifying geometry in blocks

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)

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 ?

i would guess, that your get a kind of shallow-duplicate with this line
nGons = rhObj.MeshGeometry.Ngons
and that is described here
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);
so i thinked the function linked above is the corresponding approach for instance-definitions…

hope that helps - kind regards -tom