How do I create a dialog that gives users the option of creating a new temporary feature class (polygon, polyline, points, multipart) or shapefile?

189
2
02-26-2019 10:09 PM
ShannenLeong
New Contributor

I'm trying to build a button that upon clicking, gives users an option to either create a temporary feature class or a shapefile.

If the user selects the feature class, it gives him the option to choose the type of layer (polygon, polyline, point or multipart). Then it allows the user to name the layer created or the shapefile created if the user chooses otherwise.

0 Kudos
2 Replies
ShannenLeong
New Contributor

Temporary feature class as in when created, it is stored in a scratch geodatabase.

0 Kudos
MikeRatcliffe
Occasional Contributor

Here is what I have in C# Windows Form that shortcuts the user to the built-in geoprocessing tool "create feature class" with some tweaks to the input values.  My users want a shapefile.  This sample provides a "starting point" for reference to be used in an add-in button, or in a custom Windows Form.

(Resulting inputs in the geoprocessing tool attached.)

private void Create_Shp_Click(object sender, EventArgs e)
{
if (!(Directory.Exists(GVar.DL + @"GISdata\My_Shapefiles\")))
{
try
{
new FileInfo(GVar.DL + @"
GISdata\My_Shapefiles\").Directory.Create();
}
catch (Exception)
{
MessageBox.Show(GVar.DL + @"GISdata\My_Shapefiles\ does not exist.", " Missing Outpath Folder",
MessageBoxButtons.OK,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly);
return;
}
}


string out_path = GVar.DL + @"GISdata\My_Shapefiles\";
string out_name = "
my_shapefile.shp";
var param_values = Geoprocessing.MakeValueArray(out_path,out_name);
Geoprocessing.OpenToolDialog("CreateFeatureclass_management", param_values);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos