"Item not found in this collection" error at IFeature.set_Shape(IGeometry Shape)

3717
3
08-13-2010 05:29 AM
PieterLinks
New Contributor III
Dear all,

When I want to set the shape property of a newly created feature, I get this error:[INDENT]System.Runtime.InteropServices.COMException (0x80040907): Item not found in this collection.
at ESRI.ArcGIS.Geodatabase.IFeature.set_Shape(IGeometry Shape)
at <myFunction>

[/INDENT]This is what I do:

I have two featurelayers - the one with the originating polygons which has Z, and a destination layer with polygons which has _no_ Z.[INDENT]
IFeature polygonFeature = <selected polygon feature>;
IGeometry splitGeometry = <polyline drawn by IRubberBand.TrackNew>;
IGeometry polygonGeometry = polygonFeature.ShapeCopy;
IGeometry leftSplitPart;
IGeometry rightSplitPart;
ITopologicalOperator topoOperator = polygonGeometry as ITopologicalOperator;
topoOperator.Cut(splitGeometry as IPolyline, out leftSplitPart, out rightSplitPart);
[/INDENT]The resulting geometries leftSplitPart and rightSplitPart are not empty and have the same shapetype of the featureclass I want to put them in;

Remove the Z from the leftSplitPart (with ZAware.DropZs()), but it makes no difference, because the error occurs even when I skip this step;

Start the IWorkspaceEdit::StartEditing(false) and IWorkspaceEdit::StartEditOperation (on the destination layer);[INDENT]
IFeature newFeature = destinationLayer.FeatureClass.CreateFeature();
newFeature.Shape = leftSplitPart;
[/INDENT]and there the error pops up.....

What am I doing wrong? Any ideas? I'm (still) using 9.2 SP 6.

Many thanks,
0 Kudos
3 Replies
NeilClemmons
Regular Contributor III
Have you tried setting IZAware.ZAware to False after dropping the z values?
0 Kudos
PieterLinks
New Contributor III
Dear Neil,

No, I didn't, but when I do, it works! How could I forget it..... Many thanks!

Have a nice day,
0 Kudos
MikeAdams
New Contributor II
I was getting the same error when I tried to set the shape property of a newly created feature.  After much frustration, it turned out that the shape was a point, and the feature was in a polygon type feature class.  A better error message would have helped a lot.
0 Kudos