How can I input multiple IFeatureClass objects to geoprocessing tool?

159
1
Jump to solution
11-08-2012 06:50 PM
InsuHong1
New Contributor
Hello,

I have a problem with geoprocessing.

I want to input multiple featureclasses as input for geoprocessing (in this case, Feature to Polygon tool).
I tried IGpValueTableObject, but it did not work at all.

How can I input multiple IFeatureClass objects?


Thank you


                        IGpValueTableObject vt = new GpValueTableObjectClass();                         vt.SetColumns(2);                         vt.SetColumns(2);                         object weight;                         weight = 1 as object;                         object obj1 = fcBoundary;                         vt.AddRow(ref obj1);                         vt.SetValue(0, 1, ref weight);                         object obj2 = fcPairLine;                         vt.AddRow(ref obj2);                         vt.SetValue(1, 1, ref weight);                           parameters = new VarArrayClass();                         parameters.Add(vt);                         parameters.Add("polyMerged");                         gp.Execute("FeatureToPolygon_management", parameters, null);  
Reply
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor
You almost had it. You only have to add in one column to the vt table (since this tool doesn't require the Ranks input for each feature class like the Intersect tool you asked about before) and add rows with the feature classes. Here's an example that works, written in VB.NET

        Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor         Dim vt = New ESRI.ArcGIS.Geoprocessing.GpValueTableObject         Dim FC1 As ESRI.ArcGIS.Geodatabase.IFeatureClass         Dim FC2 As ESRI.ArcGIS.Geodatabase.IFeatureClass         Dim pLayer As ESRI.ArcGIS.Carto.ILayer2         Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer         Dim params = New ESRI.ArcGIS.esriSystem.VarArray          Try             vt.SetColumns(1)             pLayer = My.ArcMap.Document.FocusMap.Layer(0)             pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer             pFLayer = pLayer             FC1 = pFLayer.FeatureClass             pLayer = My.ArcMap.Document.FocusMap.Layer(1)             pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer             pFLayer = pLayer             FC2 = pFLayer.FeatureClass              vt.AddRow(FC1)             vt.AddRow(FC2)              params.Add(vt)             params.Add("Polymerged")             GP.Execute("FeatureToPolygon_management", params, Nothing)  'here's another way to do it. You have to add the ESRI.ArcGIS.DataManagementTools reference 'using the Add Reference dialog              Dim F2P As New ESRI.ArcGIS.DataManagementTools.FeatureToPolygon              F2P.in_features = vt             F2P.out_feature_class = "poly1"              GP.Execute(F2P, Nothing)          Catch ex As Exception             System.Windows.Forms.MessageBox.Show(ex.ToString)         End Try     End Sub

View solution in original post

Reply
0 Kudos
1 Reply
KenBuja
MVP Honored Contributor
You almost had it. You only have to add in one column to the vt table (since this tool doesn't require the Ranks input for each feature class like the Intersect tool you asked about before) and add rows with the feature classes. Here's an example that works, written in VB.NET

        Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor         Dim vt = New ESRI.ArcGIS.Geoprocessing.GpValueTableObject         Dim FC1 As ESRI.ArcGIS.Geodatabase.IFeatureClass         Dim FC2 As ESRI.ArcGIS.Geodatabase.IFeatureClass         Dim pLayer As ESRI.ArcGIS.Carto.ILayer2         Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer         Dim params = New ESRI.ArcGIS.esriSystem.VarArray          Try             vt.SetColumns(1)             pLayer = My.ArcMap.Document.FocusMap.Layer(0)             pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer             pFLayer = pLayer             FC1 = pFLayer.FeatureClass             pLayer = My.ArcMap.Document.FocusMap.Layer(1)             pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer             pFLayer = pLayer             FC2 = pFLayer.FeatureClass              vt.AddRow(FC1)             vt.AddRow(FC2)              params.Add(vt)             params.Add("Polymerged")             GP.Execute("FeatureToPolygon_management", params, Nothing)  'here's another way to do it. You have to add the ESRI.ArcGIS.DataManagementTools reference 'using the Add Reference dialog              Dim F2P As New ESRI.ArcGIS.DataManagementTools.FeatureToPolygon              F2P.in_features = vt             F2P.out_feature_class = "poly1"              GP.Execute(F2P, Nothing)          Catch ex As Exception             System.Windows.Forms.MessageBox.Show(ex.ToString)         End Try     End Sub

View solution in original post

Reply
0 Kudos