<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic File geodatabase Feature class vs Shapefile Feature class in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/file-geodatabase-feature-class-vs-shapefile/m-p/1088949#M7033</link>
    <description>&lt;P&gt;I am trying to create fields of type double in my code. To do this I used&amp;nbsp;Geoprocessing.ExecuteToolAsync("AddField_management", Geoprocessing.MakeValueArray(featureclass, fieldname, type)). I do this for type double. Then I use calculate field to populate those new fields. For some reason, it works fine on file geodatabase classes, however, when I try this on shapefile feature classes it says the new fields are type text which messes up the whole program. Why is it working for some but not others? Would it be a problem with how I added the fields or something else?&lt;/P&gt;</description>
    <pubDate>Fri, 13 Aug 2021 16:51:44 GMT</pubDate>
    <dc:creator>BensonColeC</dc:creator>
    <dc:date>2021-08-13T16:51:44Z</dc:date>
    <item>
      <title>File geodatabase Feature class vs Shapefile Feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/file-geodatabase-feature-class-vs-shapefile/m-p/1088949#M7033</link>
      <description>&lt;P&gt;I am trying to create fields of type double in my code. To do this I used&amp;nbsp;Geoprocessing.ExecuteToolAsync("AddField_management", Geoprocessing.MakeValueArray(featureclass, fieldname, type)). I do this for type double. Then I use calculate field to populate those new fields. For some reason, it works fine on file geodatabase classes, however, when I try this on shapefile feature classes it says the new fields are type text which messes up the whole program. Why is it working for some but not others? Would it be a problem with how I added the fields or something else?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 16:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/file-geodatabase-feature-class-vs-shapefile/m-p/1088949#M7033</guid>
      <dc:creator>BensonColeC</dc:creator>
      <dc:date>2021-08-13T16:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: File geodatabase Feature class vs Shapefile Feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/file-geodatabase-feature-class-vs-shapefile/m-p/1089082#M7034</link>
      <description>&lt;P&gt;I will check with the dev team next week, however, i found that the order of the precision and scale parameters are switched.&amp;nbsp; Depending on those values the field type was changed.&amp;nbsp; The following snippet worked for me when using a shapfile (it's a simple button in an add-in module and all paths and values are hard coded):&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class AddDoubleToShape : Button
{
  protected override async void OnClick()
  {
	var shpPath = $@"C:\Data\FeatureTest\shapefile\base_state.shp";
	var fldName = "DTest";
    var alias = "";
	var fldType = "DOUBLE";
	var precision = 11;
    var scale = 3;
    var result = await ExecuteAddFieldTool(shpPath, fldName, alias, fldType, scale, precision, null, true);
  }

  /// &amp;lt;summary&amp;gt;
  /// Adds a field to a table using GP
  /// &amp;lt;/summary&amp;gt;
  /// &amp;lt;param name="shpPath"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="fieldName"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="fieldAlias"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="fieldType"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="precision"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="scale"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="fieldLength"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;param name="isNullable"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;returns&amp;gt;true: if field was added&amp;lt;/returns&amp;gt;
  private async Task&amp;lt;bool&amp;gt; ExecuteAddFieldTool(string shpPath, string fieldName, 
                          string fieldAlias, 
                          string fieldType, int precision, int scale,
                          int? fieldLength = null, bool isNullable = true)
  {
    try
    {
      return await QueuedTask.Run(() =&amp;gt;
      {
        // from arcpy command (from geoprocessing dockpane / share):
        // arcpy.management.AddField(r"C:\Data\FeatureTest\shapefile\base_state.shp",
        // "TestMyD", // name
        // "DOUBLE",  // type
        // 2,         // scale
        // 10,        // precision (reversed order ?  with scale ?)
        // None,      // length
        // '',        // name
        // "NULLABLE",
        // "NON_REQUIRED",
        // '')
        var parameters = Geoprocessing.MakeValueArray(shpPath, fieldName, 
          fieldType.ToUpper(), scale, precision,
          fieldLength, fieldAlias, isNullable ? "NULLABLE" : "NON_NULLABLE");
        var cts = new CancellationTokenSource();
        var result = Geoprocessing.ExecuteToolAsync("management.AddField", parameters, null, cts.Token,
            (eventName, o) =&amp;gt;
            {
              System.Diagnostics.Debug.WriteLine($@"GP event: {eventName}");
            });
        return !result.Result.IsFailed &amp;amp;&amp;amp; !result.Result.IsCanceled;
      });
    }
    catch (Exception ex)
    {
      MessageBox.Show(ex.ToString());
      return false;
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2021 00:08:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/file-geodatabase-feature-class-vs-shapefile/m-p/1089082#M7034</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2021-08-14T00:08:26Z</dc:date>
    </item>
  </channel>
</rss>

