c# custom geoprocessing function tool - how to populate a polyline output parameter?

03-11-2013 03:06 PM
Occasional Contributor
I'm at 10.1SP1 with VS2010.

In my tool's ParameterInfo property I create an output parameter of type GPLineTypeClass.

Then in the Execute() method I do work that creates an IPolyline that I want to stuff into that parameter.

PROBLEM 1: Using the GPUtilities.MakeGPValueFromObject(myIPolyline) method to get an IGPValue causes an E_FAIL COM error

So I tried this instead:

IGPLine2 outValue = new GPLineClass();
outValue.Polyline = myIPolyline;
gpUtils.PackGPValue((IGPValue)outValue, outputParam);

PROBLEM 2: But I get an invalid cast exception on that first line - GPLineClass cannot be cast to IGPLine2. What! Documentation says this class implements this interface.

SO - what is the secret sauce to stuff an IPolyline into an output parameter's value?

0 Kudos
0 Replies