Select to view content in your preferred language

CalculateAreas in ArcObjects 10

2793
2
05-03-2011 11:15 PM
by Anonymous User
Not applicable
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)
        Try
            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)

            RaiseMessage("Ready")
        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?

Regards
Magnus Mossberg, SLU
0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: jmhauck4818

Try just setting OverwriteOutput to true. Also verify that no additional applications or processes are accessing the feature class.
0 Kudos
by Anonymous User
Not applicable
Original User: Mossberg

Try just setting OverwriteOutput to true.


Thank you but that is already done, and besides there is no existing file to overwrite.

Also verify that no additional applications or processes are accessing the feature class.


I had the input shapefile opened when running the geotool, in the process that started the geotool. That worked ok in ArcGIS 9 but not in 10. If I close the input shapefile first it works.

The Error message was thus a bit confusing as it was not the output file that was the problem, but the input file.

Nevertheless, thank you for your support.

Regards
Magnus Mossberg
0 Kudos