I am using ArcObjects 10.2 to generate grid index features programmatically. I can get the correct output using the built in GUI geoprocessing tools, and with ArcPy. Furthermore, when I copy the python snippet from the result history of running the geoprocessing tool from ArcObjects, the resulting geometry is what I expect.
However, when run directly from ArcObjects, what I expect to be an array of grid features are all stacked on top of each other. How can I get the output to be an array of grid features over the input feature, just like with running the tool in the GUI?
Relevant code:
// Get the map from the map document
IMap map = mxDoc.ActiveView.FocusMap;
IActiveView activeView = map as IActiveView;
IEnvelope extent = activeView.Extent;
string outputFeatures = "in_memory\\" + lyrName;
// Set the parameters for the grid index feature tool
string polygonWidth = "32.5 Inches";
string polygonHeight = "19.2 Inches";
double scale = activeView.ScreenDisplay.DisplayTransformation.ScaleRatio;
string startingPageNumber = "1";
string originCoord = extent.XMin + " " + extent.YMin;
var geoprocessingTool = new ESRI.ArcGIS.CartographyTools.GridIndexFeatures();
geoprocessingTool.in_features = inputFeatures.Name;
geoprocessingTool.intersect_feature = "INTERSECTFEATURE";
geoprocessingTool.out_feature_class = outputFeatures;
geoprocessingTool.use_page_unit = "USEPAGEUNIT";
geoprocessingTool.scale = Convert.ToInt32(scale);
geoprocessingTool.polygon_width = polygonWidth;
geoprocessingTool.polygon_height = polygonHeight;
geoprocessingTool.number_rows = 6;
geoprocessingTool.number_columns = 5;
geoprocessingTool.starting_page_number = Convert.ToInt32(startingPageNumber);
geoprocessingTool.origin_coord = originCoord;
ExecuteGeoprocessingTool(geoprocessingTool);
To be clear, the grid index features that get create and stacked on top of each other are all created in the center of the extent.