1

I'm trying to write a custom geoprocessing function tool in ArcObjects that I can then expose as a service on ArcServer. The output parameter will be a zip file that contains a filegeodatabase. I have marked the parameter as a required and attempted to set some of the default properties of the GPDataFile class, but when I run my try task, no matter what I type into the "Output Export File" input box I get a message saying that it is required.

Does anybody have any samples on how to use and set the properties of the GPDataFile class to be used as an output parameter?

IGPDataFile gRDL = new GPDataFileClass();                
gRDL.DataType = "zip";
gRDL.DatasetName = "TableName";


IGPParameterEdit3 inputParameter = new GPParameterClass();
inputParameter.DataType = new GPDataFileTypeClass();

// Default Value object
inputParameter.Value = gRDL as IGPValue;

// Set Parameter properties
inputParameter.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
inputParameter.DisplayName = "Output Export File";
inputParameter.Name = "out_export_file";
inputParameter.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
return inputParameter;
  • Have you tried using the DEFile Class instead? It supports the IGPValue interface. This is designed for GP parameters. help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… – crmackey Jul 28 '15 at 18:32
  • Using the DEFileType over the GPDataFileTypeClass appears to work, but what is the difference between them? – blawson Jul 30 '15 at 13:51
  • That's a good question. I am not sure. To me it seems like they should both work. DEFile is from esriDataSources so maybe it is better recognized as a data source. On the other hand, GPDataFile is from Geoprocessing, which seems like it would be a better option to use for a tool parameter. Both support the IGPValue interface as well. – crmackey Jul 30 '15 at 15:11
1

I wanted to chime in on this post because although the comments from crmackey and blawson helped to solve the original question, it was difficult putting the pieces together to get a file export to work on my own custom geoprocessor.

Here is what I used for defining the output parameter in the ParameterInfo property:

IGPParameterEdit3 outputParameter = new GPParameterClass();
outputParameter.DataType = new DEFileTypeClass();
outputParameter.Value = new DEFileClass();
outputParameter.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
outputParameter.DisplayName = "Output File";
outputParameter.Name = "output_file";
outputParameter.ParameterType = esriGPParameterType.esriGPParameterTypeDerived;
parameters.Add(outputParameter);

and this is how I set the file within the Execute() method after creating a pdf file:

IGPParameter outputParameter = (IGPParameter)paramvalues.get_Element(3);
IGPValue value = new DEFileClass();
value.SetAsText(@"C:\output.pdf");
m_GPUtilities.PackGPValue(value, outputParameter);

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.