Runnung Script tools from C#

2718
1
09-11-2012 09:49 PM
ModyBuchbinder
Esri Regular Contributor
Hi All

We are trying to run system tools that are really a python scripts from Desktop 10.1 and get an error about wrong paramaters.
We are trying two methods:

IGeoProcessor pgp = new GeoProcessor();
IVariantArray parameter = new VarArrayClass();
parameter.Add(@"c:\temp\ForRT.gdb\people");
parameter.Add(@"c:\temp\ForRT.gdb\people_point_line");
pgp.Execute("PointsToLine_management", parameter , null);

or:

Geoprocessor GP = new Geoprocessor();
PointsToLine pointsToLine = new PointsToLine();
pointsToLine.Input_Features = @"C:\temp\ForRT.gdb\people";
pointsToLine.Output_Feature_Class = @"C:\temp\ForRT.gdb\people_PointsToLine";
GP.Execute( pointsToLine, null);

Both ways gives the same error.

Can anybody help?
Thanks
Mody
0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor
Have you examined the geoprocessing results to see if you're getting any more error information? I tried the following code and it worked as expected.

        Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
        Dim P2L As New ESRI.ArcGIS.DataManagementTools.PointsToLine

        Try
            P2L.Input_Features = "C:\Users\ken.buja\Documents\ArcGIS\Default.gdb\PointTest"
            P2L.Output_Feature_Class = "C:\Users\ken.buja\Documents\ArcGIS\Default.gdb\P2LTest"

            GP.Execute(P2L, Nothing)

        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show(ex.ToString)
        End Try
0 Kudos