Constructing an envelope from multiple features in a feature cursor

Discussion created by narsdani on Apr 11, 2011
Latest reply on Apr 11, 2011 by Neil
I've got a feature cursor queried from a polygon feature class (the parcel feature class of a parcel fabric, in case that makes a difference) and I want to loop through it and construct an envelope of all of the features in it.  I've tried creating a GeometryBag object, shoving each polygon into it, QIing to an ITopologyOperator, doing ITopologyOperator::ConstructUnion(), then getting the envelope of the result.  I've also tried creating an empty Envelope object and putting pEnvelope.Union(eachCursorFeature.ShapeCopy.Envelope) inside the loop of cursor features.

In both cases above, I tried using both the eachCursorFeature.ShapeCopy and eachCursorFeature.Shape properties of the feature.  But all four tries yield the envelope of only one of the features.

This must be some issue with a feature or shape being passed by reference or something like that, yes?  I can't figure out where that is.  Can anyone enlighten me?