rkoc

Geoprocessing Using ArcObjects - Feature Class to Feature Class...

Discussion created by rkoc on Jun 11, 2010
Latest reply on Jun 13, 2010 by rkoc
Hi,

I am writing an extension for ArcMap using ArcObjects and VB.Net. As part of this extension I would like to access the �??Feature Class to Feature Class�?? geoprocessing tool using ArcObjects.

Using the example in http://edndoc.esri.com/arcobjects/9.2/CPP_VB6_VBA_VCPP_Doc/COM/gp/Using%20Geoprocessing%20Tools%20in%20VB.pdf as a guide, I have managed to come up with the code below. This code however causes ArcMap to crash at the GP.Execute line.

I have read the help file for this tool which suggests that the �??in_features�?? and �??out_path�?? need to be of types  IFeatureLayer and IWorkspace respectively. Unfortunately I don�??t know how to set the properties correctly for this interface. http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/conversion_tools/feature_class_to_feature_class_conversion_.htm

Also am I correct in setting the optional parameters to Nothing? Or should I not declare/set these at all?

To start with I�??m just looking to go from SHP to SHP, but ultimately the goal will be SHP to SDE.

Can anyone help me out?

Thanks. Rob.

  Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim GP As IGeoProcessor = New GeoProcessor
        'Dim gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor

        'Declare variables for input
        Dim in_features As String
        Dim out_path As String
        Dim out_name As String
        Dim where_clause As String
        Dim field_mapping As String
        Dim config_keyword As String

        'Define the input/output parameter
        in_features = "C:\temp\roads.shp"
        out_path = "C:\temp"
        out_name = "aaa.shp"
        where_clause = Nothing
        field_mapping = Nothing
        config_keyword = Nothing

        'Declare and set a variant array
        Dim parameters As IVariantArray
        parameters = New VarArray

        'Populate the variant array with
        parameters.Add(in_features)
        parameters.Add(out_path)
        parameters.Add(out_name)
        parameters.Add(where_clause)
        parameters.Add(field_mapping)
        parameters.Add(config_keyword)

        'GP.FeatureclassToFeatureclass_conversion(in_features, out_path, out_name)
        GP.Execute("FeatureclassToFeatureclass_conversion", parameters, Nothing)

    End Sub

Outcomes