Editing and shape length

1609
1
03-10-2016 08:09 AM
GéomatiqueSopfeu
New Contributor

I need your help!

I have a very simple polygon shape. In an edit session, I want to show the shape lenght of the modified polygon "in real time" (meaning that everytime a point of the polygon is moved, I'll show the new patrol length in a label). My OnSketchModified fire up correctly, it is just that I don't know how to calculate the lenght.

Thanks !

0 Kudos
1 Reply
AhmedEl-Sisi
Occasional Contributor III

Hi,

If you have the polygon geometry you can cast it to ICurve interface and get its Length, something like the following:

 private double GetShapeLength(IGeometry geometry)
  {
            double geometryLength = 0;
            if (geometry!=null&&geometry.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                ICurve curve = geometry as ICurve;
                geometryLength= curve.Length;
            }
            return geometryLength;
 }