Wednesday, July 1, 2009

Creating a Feature Set via C#

A very powerful model builder feature is the create variable option. This will allow users to create almost any type of user input desire. The feature set variable is a very helpful variable when a user needs to interact with the map or recordset. The feature set allows users to draw points, polylines, or polygons on the fly. To do this in C#, you need to use the IGPRecordSetLayerClass(), but the process of making the interactive part work isn't that straight forward.

To get the interactive part of the Feature set to work, you must define the Schema with either a layer file or feature class in model builder. When you take a look at the ArcObject description of a parameter, you notice a pointer called Schema, but this isn't where you define the template data for a GPFeatureRecordSet, you define it in Value().


inputParameter.DataType = new GPFeatureRecordSetLayerTypeClass();
//
// create the GP Feature Recordset Layer Object
// from template data
//
IFeatureClass FC = (IFeatureClass)m_GPUtilities.OpenDatasetFromLocation( @"