cheynm@yahoo.com

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

Discussion created by cheynm@yahoo.com on Mar 11, 2013
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?

Thanks!

Outcomes