How to pass Table View data type to Append Geoprocessor in VBNET

Discussion created by tbarker3440 on May 17, 2013
Latest reply on May 20, 2013 by kenbuja

I have a vbnet component program originally coded around version 9.x.  It successfully used strings to pass input feature names and output feature names to Intersect and Append tools using the geoprocessor approach.  This no longer works in Desktop v10.1.  I get the cryptic HRESULT E_FAIL error.  After much anguish, I discovered it was really throwing error 000628 - it didn't like the data type of the passed in parameter.  Turns out Intersect wants the the input_features in a Value Table data form.  The following code now works for Intersect

Dim GP As Geoprocessor = New Geoprocessor
        GP.AddOutputsToMap = False
        'GP.AddOutputsToMap = True

        GP.OverwriteOutput = True

        GP.LogHistory = True

        'Calculate feature names with paths and put in data types required to pass to the geoprocessor
        Dim polygonFileName As String = GolderGISTools.Utilities.Utility.GetLayerPathAndName(modelSetting.PolygonFeatureClassNames(1), Me._mxDocument) & ".shp"
        Dim gpUtils As IGPUtilities2 = New GPUtilitiesClass()
        Dim inFeature1 As IFeatureClass = gpUtils.OpenFeatureClassFromString(modelSetting.OutputDataPath & "\fishnet.shp")
        Dim inFeature2 As IFeatureClass = gpUtils.OpenFeatureClassFromString(polygonFileName)
        'Create and populate a Value Table Object to hold the input features to be intersected
        Dim vt As IGpValueTableObject = New GpValueTableObjectClass()

        Dim obj1 As Object = inFeature1
        Dim obj2 As Object = inFeature2
        'Run the Tool
        Dim intersect As ESRI.ArcGIS.AnalysisTools.Intersect = New ESRI.ArcGIS.AnalysisTools.Intersect()
        'Dim union As ESRI.ArcGIS.AnalysisTools.Union = New ESRI.ArcGIS.AnalysisTools.Union()
        intersect.in_features = vt
        intersect.out_feature_class = tempDirectoryInfo.FullName & "\temp.gdb\" & "intersect"
        intersect.join_attributes = "ALL"
        intersect.output_type = "INPUT"

            GP.Execute(intersect, Nothing)
            intersect = Nothing
            ReturnMessages(GP, modelSetting.OutputDataPath & "\log.txt")
            If GP.MaxSeverity = 2 Then
                MessageBox.Show("Error intersect Fishnet with LT/FT, see log file", "error in ALCES Mapper", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "error intersect Fishnet with LT/FT", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ReturnMessages(GP, modelSetting.OutputDataPath & "\log.txt")
            Return False
        End Try
        intersect = Nothing
        vt = Nothing
        obj1 = Nothing
        obj2 = Nothing

        'While Marshal.ReleaseComObject(intersect) > 0
        'End While


The Append tool uses a Table View or Raster Feature as the Input and Target parameters.  I have tried many combinations to duplicate the above example with this composite data type.  All I want is to assign two shape files to the input and target parameters so I can execute an append.  I clearly am missing something basic here about the object oriented nomenclature.

Input will be :  tempDirectoryInfo.FullName & "\temp.gdb\" & "intersect1.shp"
Target will be: tempDirectoryInfo.FullName & "\temp.gdb\" & "intersect.shp"


Tim Barker
Innovative Forest Analytics Ltd