juriggs

Passing multiple values to the .NET Geoprocessor Class

Discussion created by juriggs on Apr 16, 2010
Latest reply on Apr 20, 2010 by elrobis
Hi,

I've been working on a little issue for a few days now, and can't seem to identify the problem. Maybe a pair of fresh eyes can see what I'm missing.

What I'm trying to do is pass in multiple input values using the Geoprocessor class. I found a great article at

http://blogs.esri.com/Dev/blogs/arcobjectsdevelopment/archive/2009/06/08/ArcGIS-Developer-Tip-_2300_3_3A00_-Passing-multiple-values-to-the-.NET-Geoprocessor.aspx

that explains how to do this, but there are two things I don't understand.

1) In all the examples, the author sets the parameters to physical locations such as "C:\temp\union_output.shp". That's fine, but I'd like to set my parameters to the value of a variable such as txtOutput.Txt. This doesn't seem to work - when I debug, there's nothing in the output workspace parameter.

2) This will take a bit more explaining. In the example, the author uses this code:

Example: Use a GpValueTableObject (probably the least widely known method, but very powerful!)

'Feature Class Objects

Dim gpUtils As IGPUtilities2 = New GPUtilitiesClass()
Dim inFeature1 As IFeatureClass = gpUtils.OpenFeatureClassFromString("C:\temp\test.gdb\states")
Dim inFeature2 As IFeatureClass = gpUtils.OpenFeatureClassFromString("C:\temp\test.gdb\counties")

'Create and populate a Value Table Object

Dim vt As IGpValueTableObject = New GpValueTableObjectClass()       
vt.SetColumns(1)
Dim obj1 As Object = inFeature1
vt.AddRow(obj1)
Dim obj2 As Object = inFeature2
vt.AddRow(obj2)

'Run the Tool

Dim union As ESRI.ArcGIS.AnalysisTools.Union = New ESRI.ArcGIS.AnalysisTools.Union()
union.in_features = vt
union.out_feature_class = "C:\temp\Union_Output.shp"
GP.Execute(union, Nothing)

In my application, I can have either feature classes or datasets as inputs. How will that change things? More importantly, the number of inputs is unknown. In this example, just creates 2 IFeatureClass variables. My input parameters are held in a listbox, and I need to be able to create as many variables as there are files. Could anybody point me in the right direction as to how I could code this?

Thanks for the help...

Justin

Outcomes