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..
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.
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.