2

I'm developing an arcobjects 10.4.1 custom GeoProcess (fusion shift) which has to be able to run within a model builder. The GeoProcess seems to run smoothly, but the problem is it needs to be outputting a resultant feature class that needs to be reused afterwards. The resultant feature class path is being generated correctly and the feature class is there at the end, but the node doesn't turn green nor shades, so it cannot be reused.

Fusion Shift GP and resultant feature class

This is the code i'm using to statically define this resultant feature class field:

            outputParameter = new GPParameterClass();
            outputParameter.DataType = new GPFeatureLayerTypeClass();
            outputParameter.Value = new GPFeatureLayerClass();
            outputParameter.ParameterType = esriGPParameterType.esriGPParameterTypeDerived;
            outputParameter.DisplayName = "Resultant feature class";
            outputParameter.Name = "ResultantFeatureClass";
            outputParameter.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
            outputParameter.AddDependency("ShiftedWorkspace");
            outputParameter.AddDependency("ShiftedFeatureClassName");

            IGPFeatureSchema outSchema = new GPFeatureSchemaClass();
            outSchema.FieldsRule = esriGPSchemaFieldsType.esriGPSchemaFieldsNone;
            outSchema.FeatureTypeRule = esriGPSchemaFeatureType.esriGPSchemaFeatureFirstDependency;

            IGPSchema schema = outSchema as IGPSchema;
            schema.GenerateOutputCatalogPath = true;
            outputParameter.Schema = (IGPSchema)outSchema;

            parameters.Add(outputParameter);

And this piece of code is executed once in the update parameters method:

            // Output parameter feature class
            IGPParameter3 gpParamOutputMasterLayer = (IGPParameter3)m_Parameters.Element[++parameterCount];
            IGPParameterEdit3 gpParamOutputMasterLayerEdit = (IGPParameterEdit3)gpParamOutputMasterLayer;
            if (!gpValue.IsEmpty()) gpParamOutputMasterLayerEdit.Value = m_GPUtilities.UnpackGPValue(gpValue);

What am I missing? is there something else I need to define?

1

I've personally never created a GeoProcessing tool in ArcObjects so the only thing I can offer is that there is a whole section on building such tools in the API help file and they have moved examples which are probably worth looking at to see whats different to their GitHub site.

| improve this answer | |
  • Thanks anyway for your input Hornbydd. I checked them out but those samples didn't seem to fit into my GP needs. Didn't even have GUI. – Jose May 5 at 12:00
1

Found this ESRI sample ConvexHull ESRI which revealed what I was doing wrong. Basically indicated output parameter to required instead of derived and switched its type to feature class instead of feature layer. Ath the end no IGPSchema was needed. Here's the working code:

            outputParameter = new GPParameterClass();
            outputParameter.DataType = new DEFeatureClassTypeClass();
            outputParameter.Value = new DEFeatureClassClass();
            outputParameter.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
            outputParameter.DisplayName = "Resultant feature class";
            outputParameter.Name = "ResultantFeatureClass";
            outputParameter.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
            parameters.Add(outputParameter);

Then in the UpdateParameters method, you decode your values into whatever form you need to execute your GP.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.