custom .Net geoprocessing tool output is not chaining in modelbuilder

09-02-2011 08:29 AM
New Contributor III
I have a "simple" custom .net geoprocessing tool that accepts a polygon feature class as an input and modifies the feature geometry.  I am shooting for something like the "repair geometry" tool that makes edits to the input FC

The tool executes when run independently. When added to model builder, the output from this tool validates but is not a valid input for other tools when chained together

This is my first attempt at Building geoprocessing tool in .NET, so pretty much any help is appreciated
I used the calculate area and convexHull GPtool examples as a starting point

I am not sure where the error is with the parameter definition or in the execute sub not returning something

Any help is appreciated, complete Code is attached..
0 Kudos
4 Replies
New Contributor

The update of the output parameter value is incorrect. I would first try just deleting the following code. Implement IGPFunction2 instead of IGPFunction. You do not need to implement any code in UpdateParameters and UpdateMessages, the schema.clonedependency = true should update the output correctly.

                ' Get the output parameter
                Dim output_parameter As IGPParameter3 = CType(paramvalues.Element(1), IGPParameter3)

                ' Unpack the output parameter value..
                'This ensures you get the value either form the DataElement or MdVariable (modelbuilder)

                Dim outputValue As IGPValue = m_GPUtilities.UnpackGPValue(output_parameter)

                'set output to modified input to enable output validation for modelbuilde?
                outputValue = parameterValue
                m_GPUtilities.PackGPValue(outputValue, inputFeatureClass)

If that does not work, do the following. This updates the output parameter with the input value.

               ' Get the output parameter
                Dim output_parameter As IGPParameter3 = CType(paramvalues.Element(1), IGPParameter3)
                m_GPUtilities.PackGPValue(parameterValue, output_parameter)

Also remove the InternalValidate call from execute, it is unnecessary. The check to fail if DecodeFeatureLayer fails is all you need.

You probably already know about this link, but just in case, check this out for more details.

0 Kudos
New Contributor III
Thanks for the quick reply

I had a feeling the output parameter was taken care of by the cloning.  Thanks for validation

I tried to implement IGPFunction2 but for some reason it is not recognizing the interface members and throwing errors. 

OK so apparently you have to overload the tool with both  IGPfunction and IGPfunction2 members

Thanks for the link, I was looking in the 9.3 help files but that is outdated. 
Ugh, Navigating through the new help site is the harders part!
0 Kudos
New Contributor III
Something in The changes suggested and implemented are causing the tool to fail by blinking out when run against a large data set (1700 features) but not against the test (3 features)

Any suggestions on debugging the code?

I have VS 2010 EXPRESS and am not sure how to define this as a windows form application
or how to define a startup application / debugging environment...
0 Kudos
Esri Regular Contributor

OK so apparently you have to overload the tool with both IGPfunction and IGPfunction2 members

If you are using VB .NET then you have to implement both IGPFunction2 and IGPFunction. Actually, implement IGPFunctiojn2 first and then in the implementation of IGPFunction just call IGPFunction2 methods.

If you are using C# then implementing just IGPFunction2 is enough.
0 Kudos