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!
Solved! Go to Solution.
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());
}
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());
}
The issue was one need to add "JoinAttributes" - value "ALL" and then add XY tolerance.
understand, thank you!