Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm currently using the LocateFeaturesAlongRoutes tool wrapper for C#/.NET for a custom tool I'm developing for ArcMap 9.3.1. I've been able to run this tool in ArcMap outside of code in a tool with the same files as parameters.

Unfortunately when I put it in code I keep getting null for the IGeoProcessorResult. Is there any reason why I would get a null object for the result instead of just saying it failed? Also, is there anything wrong with the below code?

The relevant block of code is below.

LocateFeaturesAlongRoutes lfar = new LocateFeaturesAlongRoutes();
lfar.in_features = @"C:\GIS_Temp\CONGPROP.mdb\CONGPROP2";
lfar.in_routes = @"C:\GIS_Temp\Routes.mdb\routes";
lfar.route_id_field = "ROUTE_ID";
lfar.out_table = "eventTable.dbf";
lfar.out_event_properties = "ROUTE_ID LINE FMEAS TMEAS";
lfar.in_fields = "NO_FIELDS";

Geoprocessor geoprocessor = new Geoprocessor();
geoprocessor.TemporaryMapLayers = false;
geoprocessor.OverwriteOutput = true;
geoprocessor.AddOutputsToMap = true;
IGeoProcessorResult result = (IGeoProcessorResult) geoprocessor.Execute(lfar, null);

Any suggestions?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Turns out that the result will return null if any of the inputs to the tool are not correct. I found the best way when you don't know all of the parameters is to get the Python script from a run of the tool that was successful. This will at least get how the parameters should look, and that can be converted to .NET.

share|improve this answer
    
+1 Sounds like an acceptable answer to me. Please check the "accept" box. –  Kirk Kuykendall Apr 3 '13 at 21:04
    
Still getting used to this... I guess I didn't have enough confidence to say I answered my own question :) –  Daniel Reeves Apr 3 '13 at 21:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.