Error: The geometry is not Z-aware

1900
1
Jump to solution
07-24-2017 07:06 AM
ShaningYu
Frequent Contributor

In my ArcObjects projects, there is a function to Insert a polygon feature from a Source FeatureClass into a Target FeatureClass (fc_Target).  The related code is below:
    IFeature f_Target = fc_Target.CreateFeature();
    f_Target.Shape = f_Source.Shape;   // f_Source - feature of Source FeatureClass; Got error
However, it throws an error:  The geometry is not Z-aware.  Then, I found that the fc_Source is a type of PlogonZM, while the fc_Target is type of Polygon.  How can this problem be fixed?  Thanks.

0 Kudos
1 Solution

Accepted Solutions
ShaningYu
Frequent Contributor

The reported error was gone with the code below:

            IZAware zAware = (IZAware)f_Source.Shape;
            if (zAware.ZAware != false) {
                zAware = (IZAware)f_Source.Shape;
                zAware.DropZs();
                zAware.ZAware = false;
            }

            IZAware zAware2 = (IZAware)f_Target.Shape;
            f_Target.Shape = f_Source.Shape;

Thanks for your review.

View solution in original post

1 Reply
ShaningYu
Frequent Contributor

The reported error was gone with the code below:

            IZAware zAware = (IZAware)f_Source.Shape;
            if (zAware.ZAware != false) {
                zAware = (IZAware)f_Source.Shape;
                zAware.DropZs();
                zAware.ZAware = false;
            }

            IZAware zAware2 = (IZAware)f_Target.Shape;
            f_Target.Shape = f_Source.Shape;

Thanks for your review.