<?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 Re: CreateFeatureClass Error in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1112915#M7310</link>
    <description>&lt;P&gt;I really do not like that SDK developers have to call Geoprocessing.ExecuteToolAsync for anything.&amp;nbsp; Unfortunately, as of today, you do need to call it for a lot of things... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp; &amp;nbsp;That being said I have a few&amp;nbsp; recommendations for you.&lt;/P&gt;&lt;P&gt;1. When you're using Geoprocessing.ExecuteToolAsync you're basically doing what a user can do via the ArcGIS Pro User interface.&amp;nbsp; So make sure you can actually use the GP Tool via the UI first.&amp;nbsp; That will provide some insight and clarify and misunderstandings you might have about the GP Tool does or does not do.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Running the GP Tool through the UI produces "Details" when complete which will reveal the proper syntax for some of the arguments.&amp;nbsp; As an example I would have never figured out, on my own, how to properly format Field Maps without doing this.&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; For this particular GP Tool, I use "CreateFeatureClass_management" but I think the syntax you're using is valid too.&amp;nbsp; I also use this tool to only create actualy feature classes in a geodatabase so don't know about Shapefiles but the documentation syntax does show shapefiles so should work too.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my syntax for an actual Feature Class if it helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            List&amp;lt;object&amp;gt; arguments = new List&amp;lt;object&amp;gt;
            {
                CoreModule.CurrentProject.DefaultGeodatabasePath, // use the default geodatabase
                featureclassName,                                 // name of the feature class
                featureclassType,                                 // type of geometry
                "",                                               // no template
                "DISABLED",                                       // no m values
                "ENABLED",                                        // no z values
                a_spatialReference
            };

            IGPResult l_returnResult = await Geoprocessing.ExecuteToolAsync("CreateFeatureclass_management", Geoprocessing.MakeValueArray(arguments.ToArray()));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just before hitting Reply, I reviewed your code again and your parameters are also incorrect.&amp;nbsp; You left off the template, has_m, and has_z arguments so in essence you're passing your Spatial Reference as the Template argument.&amp;nbsp; &amp;nbsp;Hope that helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW.... The main problem with having to call the GP Tool this way as there is no syntax checking by the C# compiler for that as the parameters are passed as an instance of a List&amp;lt;object&amp;gt;.&amp;nbsp; So calling a GP Tool is a lot of trial and error with no help from the compiler... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Nov 2021 18:48:18 GMT</pubDate>
    <dc:creator>DanielHuantes</dc:creator>
    <dc:date>2021-11-01T18:48:18Z</dc:date>
    <item>
      <title>CreateFeatureClass Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1112827#M7308</link>
      <description>&lt;P&gt;Good day,&lt;BR /&gt;I'm trying to create a featureClass, but I'm making a mistake somewhere but I don't know where ...&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; protected override async void OnClick()
        {
            await CreateMyLineAsync();
        }
        private static async Task CreateMyLineAsync()
        {
            await QueuedTask.Run(async () =&amp;gt;
            {
                var spatialReference = SpatialReferenceBuilder.CreateSpatialReference(5514);
                await CreateFeatureClass(@"D:\classToClass", "Linie.shp", "POLYLINE", "", "DISABLED", "DISABLED", spatialReference);
            });
        }
        private static async Task CreateFeatureClass(string Output, string name, string geometryType, string template, string has_m
            , string has_z, SpatialReference spatialReference)
        {
            var parameters = Geoprocessing.MakeValueArray(Output, name, geometryType, spatialReference);
            var selectLayer = "management.CreateFeatureclass";
            await FunctionPart(selectLayer, parameters);
        }
        private static async Task FunctionPart(string stringFunc, IReadOnlyList&amp;lt;string&amp;gt; parameters)
        {
            try
            {
                await Geoprocessing.ExecuteToolAsync(stringFunc, parameters).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString(), Assembly.GetExecutingAssembly().FullName);
                throw;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;I'll be very happy if someone tells me where the mistake is.The application passes the code but does not create either a shapefile in the file or a layer in the map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 12:47:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1112827#M7308</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-11-01T12:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: CreateFeatureClass Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1112915#M7310</link>
      <description>&lt;P&gt;I really do not like that SDK developers have to call Geoprocessing.ExecuteToolAsync for anything.&amp;nbsp; Unfortunately, as of today, you do need to call it for a lot of things... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp; &amp;nbsp;That being said I have a few&amp;nbsp; recommendations for you.&lt;/P&gt;&lt;P&gt;1. When you're using Geoprocessing.ExecuteToolAsync you're basically doing what a user can do via the ArcGIS Pro User interface.&amp;nbsp; So make sure you can actually use the GP Tool via the UI first.&amp;nbsp; That will provide some insight and clarify and misunderstandings you might have about the GP Tool does or does not do.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Running the GP Tool through the UI produces "Details" when complete which will reveal the proper syntax for some of the arguments.&amp;nbsp; As an example I would have never figured out, on my own, how to properly format Field Maps without doing this.&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; For this particular GP Tool, I use "CreateFeatureClass_management" but I think the syntax you're using is valid too.&amp;nbsp; I also use this tool to only create actualy feature classes in a geodatabase so don't know about Shapefiles but the documentation syntax does show shapefiles so should work too.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my syntax for an actual Feature Class if it helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            List&amp;lt;object&amp;gt; arguments = new List&amp;lt;object&amp;gt;
            {
                CoreModule.CurrentProject.DefaultGeodatabasePath, // use the default geodatabase
                featureclassName,                                 // name of the feature class
                featureclassType,                                 // type of geometry
                "",                                               // no template
                "DISABLED",                                       // no m values
                "ENABLED",                                        // no z values
                a_spatialReference
            };

            IGPResult l_returnResult = await Geoprocessing.ExecuteToolAsync("CreateFeatureclass_management", Geoprocessing.MakeValueArray(arguments.ToArray()));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just before hitting Reply, I reviewed your code again and your parameters are also incorrect.&amp;nbsp; You left off the template, has_m, and has_z arguments so in essence you're passing your Spatial Reference as the Template argument.&amp;nbsp; &amp;nbsp;Hope that helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW.... The main problem with having to call the GP Tool this way as there is no syntax checking by the C# compiler for that as the parameters are passed as an instance of a List&amp;lt;object&amp;gt;.&amp;nbsp; So calling a GP Tool is a lot of trial and error with no help from the compiler... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 18:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1112915#M7310</guid>
      <dc:creator>DanielHuantes</dc:creator>
      <dc:date>2021-11-01T18:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: CreateFeatureClass Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1113508#M7317</link>
      <description>&lt;P&gt;Thank you very much for your answer. Yes, one of the bugs was incorrect parameter placement, moreover, this method does not create a new shapefile but must take an already created one, so I had it wrong as well.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 06:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/createfeatureclass-error/m-p/1113508#M7317</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-11-03T06:20:13Z</dc:date>
    </item>
  </channel>
</rss>

