AnsweredAssumed Answered

c# Custom GP function tool - calling another tool in the same DLL

Question asked by mreddick on May 19, 2016
Latest reply on May 19, 2016 by mreddick

I'm writing a custom c# GP DLL that defines multiple tools (SolveRoute & CostRoute) that can be added to a toolbox. In some cases they will be run individually in some cases SolveRoute will automatically call CostRoute.

 

Solve Route does a bunch of Network Analyst stuff and creates some line work.

 

Cost Route generates associated costing info for that route.

 

So i have the 2 tool classes defined in one DLL that both implement IGPFunction2, IGPToolBackground and i can see both in the toolbox.

My question though is around how i go about calling the CostRoute tool from within the SolveRoute tool in its Execute method.

I've tried doing something similar to this but even with no params it seems to throw an error.

 

            IVariantArray parameters = new VarArrayClass();

            // add some params here

            gp.Execute("SolveRoute", parameters, track);

I've seen other code where the tools are created e.g new DeleteFeatures and then the parameters are set. I'm not sure if this the correct way to go. Is there any help documenting this more complex case of a DLL with multiple tools or can anyone give any pointers having done this before?

thanks

mark

Outcomes