AnsweredAssumed Answered

CalculateAreas in ArcObjects 10

Question asked by geonetadmin on May 3, 2011
Latest reply on May 5, 2011 by geonetadmin
Original User: Mossberg

I have a small pice of code that has been working well under ArcObjects 9 but refuses to run under ArcObjects 10.

Private Sub CalculateAreas(ByVal inPath As String, ByVal inName As String, ByVal outPath As String, ByVal outName As String)
            RaiseEvent Message("Calculate areas...")

            Dim gptool As SpatialStatisticsTools.CalculateAreas = New SpatialStatisticsTools.CalculateAreas

            gptool.Input_Feature_Class = inPath & inName
            gptool.Output_Feature_Class = outPath & outName

            mvarGeoProc.Execute(gptool, Nothing)

        Catch ex As Exception
            ShowGeoProcMessage("Calculate areas")
            RaiseMessage("Error : " & ex.Message)
        End Try
    End Sub

All it does is, using geoprocessing tool, to calculate the areas of the features in a shape file. When I run it under ArcObjects 10 I recive the following error

Executing: CalculateAreas C:\ArcWork\test\hchange_study.shp C:\ArcWork\test\hchange_area.shp
Start Time: Wed May 04 08:48:56 2011
Running script CalculateAreas...
ERROR 000903: Cannot overwrite: C:\ArcWork\test\hchange_area.shp
ERROR 000852: Cannot add field F_AREA to C:\ArcWork\test\hchange_area.shp
<class 'ErrorUtils.ScriptError'>: Exiting....
Failed to execute (CalculateAreas).
Failed at Wed May 04 08:48:56 2011 (Elapsed Time: 0.00 seconds)

Thus the geoprocessor complains that it can't overwrite the output file. Well there is no output file to overwrite. 

If I run the CalculateAreas tool from the ArcToolbox using the same input file and name of output file it works. But not from within ArcObjects.

Any tips on what might cause the problem under ArcObjects 10?

Magnus Mossberg, SLU