Select to view content in your preferred language

vb.net arcobjects run Geoprocessing tool with optional parameter

2587
3
Jump to solution
09-23-2014 08:05 PM
LiYao
by
Deactivated User

Dear all,

I am using vb.net arcobjects to run the intersect geoprocessing tool. When I use all the required parameters, it works. But if I add an optional parameter, it not work.

My code is as bellows:

Dim GP As GeoProcessor = New GeoProcessor()

Dim parameters As IVariantArray = New VarArray

parameters.Add("test_db.DBO.Segment;test_db.DBO.LINE")

parameters.Add("D:\local\Segment_line_intersect")

parameters.Add("0.5 Meters")  ' this is an optional parameter for XY tolerance


"Intersect_Analysis", parameters, Nothing)

When I add the parameter of XY tolerance, it will cause error. I wonder is anything missing in my code? Thanks!

0 Kudos
1 Solution

Accepted Solutions
ShriramBhutada1
Deactivated User

Hi Li,

The below code should work. I've tested it on my computer.

    RuntimeManager.Bind(ProductCode.Desktop);
            GeoProcessor gp =new  GeoProcessor();
            IVariantArray parameters = new VarArrayClass();
              
            //input layer location
         
            parameters.Add(@"C:\\junk\\TemplateData1e.gdb\\USA\\counties;C:\\junk\\TemplateData1e.gdb\\USA\\states");
            parameters.Add(@"C:\\Users\\shri7493\\Documents\\ArcGIS\\Default.gdb\\counties_Intersect");
            parameters.Add("ALL");
            parameters.Add("0.34 Meters");
            parameters.Add("INPUT");
            IGeoProcessorResult gpResult = gp.Execute("Intersect_Analysis", parameters, null);
            for (int i = 0; i < gpResult.MessageCount; i++)
            {
            Console.Write (gpResult.GetMessage(i).ToString());
            }

View solution in original post

0 Kudos
3 Replies
ShriramBhutada1
Deactivated User

Hi Li,

The below code should work. I've tested it on my computer.

    RuntimeManager.Bind(ProductCode.Desktop);
            GeoProcessor gp =new  GeoProcessor();
            IVariantArray parameters = new VarArrayClass();
              
            //input layer location
         
            parameters.Add(@"C:\\junk\\TemplateData1e.gdb\\USA\\counties;C:\\junk\\TemplateData1e.gdb\\USA\\states");
            parameters.Add(@"C:\\Users\\shri7493\\Documents\\ArcGIS\\Default.gdb\\counties_Intersect");
            parameters.Add("ALL");
            parameters.Add("0.34 Meters");
            parameters.Add("INPUT");
            IGeoProcessorResult gpResult = gp.Execute("Intersect_Analysis", parameters, null);
            for (int i = 0; i < gpResult.MessageCount; i++)
            {
            Console.Write (gpResult.GetMessage(i).ToString());
            }

0 Kudos
ShriramBhutada1
Deactivated User

The issue was one need to add "JoinAttributes" - value "ALL" and then add XY tolerance.

0 Kudos
LiYao
by
Deactivated User

understand, thank you!

0 Kudos