<?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: Open a feature class in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211180#M8736</link>
    <description>&lt;P&gt;Excellent Reply... Worked well.&lt;/P&gt;&lt;P&gt;FYI for others, the Path.GetDirectoryName() needs the "using System.IO;" statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Sep 2022 17:18:37 GMT</pubDate>
    <dc:creator>JeromeHaaland</dc:creator>
    <dc:date>2022-09-09T17:18:37Z</dc:date>
    <item>
      <title>Open a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211006#M8729</link>
      <description>&lt;P&gt;The GetBoundary() method below returns the string path to a feature class.&lt;/P&gt;&lt;P&gt;How is the string path to the feature class used instead of the code on lines 25 and 26?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
        {
            string extent = await Extent();
            MessageBox.Show(extent);

            static async Task&amp;lt;string&amp;gt; Extent()
            {
                string results = "";

                static string GetBoundary()
                {
                    OpenItemDialog item = new OpenItemDialog();
                    item.Title = "Select the Boundary";
                    item.MultiSelect = false;
                    item.ShowDialog();
                    return item.Items.First().Path;
                }

                await QueuedTask.Run(() =&amp;gt;
                {
                    // Want to use this path name to create a feature class
                    string boundary = GetBoundary();

                    // This is fine... except how are the 2 lines below made to run from an OpenItemDialog
                    Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("C:\\Temp\\Learn.gdb")));
                    using (FeatureClass fc = gdb.OpenDataset&amp;lt;FeatureClass&amp;gt;("CSS_1_BoundaryBuffer"))
                    {
                        string xMax = fc.GetExtent().XMax.ToString();
                        string xMin = fc.GetExtent().XMin.ToString();
                        string yMax = fc.GetExtent().YMax.ToString();
                        string yMin = fc.GetExtent().YMin.ToString();

                        results = $"{xMin} {yMin} {xMax} {yMax}";
                    }
                });
                return results;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 01:55:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211006#M8729</guid>
      <dc:creator>JeromeHaaland</dc:creator>
      <dc:date>2022-09-09T01:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Open a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211032#M8730</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your code structure isn't correct. You need to separate UI and work tasks first. I would do it like that:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        static string GetBoundary()
        {
            OpenItemDialog item = new OpenItemDialog();
            item.Title = "Select the Boundary";
            item.MultiSelect = false;
            item.ShowDialog();
            return item.Items.First().Path;
        }

        static async Task&amp;lt;string&amp;gt; Extent(string fcPath)
        {
            string results = "";

            await QueuedTask.Run(() =&amp;gt;
            {
                // Want to use this path name to create a feature class
                string boundary = GetBoundary();

                // This is fine... except how are the 2 lines below made to run from an OpenItemDialog
                Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Path.GetDirectoryName(fcPath))));
                using (FeatureClass fc = gdb.OpenDataset&amp;lt;FeatureClass&amp;gt;(Path.GetFileName(fcPath)))
                {
                    string xMax = fc.GetExtent().XMax.ToString();
                    string xMin = fc.GetExtent().XMin.ToString();
                    string yMax = fc.GetExtent().YMax.ToString();
                    string yMin = fc.GetExtent().YMin.ToString();

                    results = $"{xMin} {yMin} {xMax} {yMax}";
                }
            });
            return results;
        }

        protected override async void OnClick()
        {
            string fcPath = GetBoundary();
            string extent = await Extent(fcPath);
            MessageBox.Show(extent);
        }&lt;/LI-CODE&gt;&lt;P&gt;I have added fcPath parameter for your Extent method. fcPath parameter value separated by Path methods to Directory and File name.&lt;/P&gt;&lt;P&gt;I would recommend to use FeatureClass filter in your GetBoundary method.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Browse-Dialog-Filters" target="_self"&gt;https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Browse-Dialog-Filters&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 05:38:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211032#M8730</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-09-09T05:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Open a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211180#M8736</link>
      <description>&lt;P&gt;Excellent Reply... Worked well.&lt;/P&gt;&lt;P&gt;FYI for others, the Path.GetDirectoryName() needs the "using System.IO;" statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 17:18:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-a-feature-class/m-p/1211180#M8736</guid>
      <dc:creator>JeromeHaaland</dc:creator>
      <dc:date>2022-09-09T17:18:37Z</dc:date>
    </item>
  </channel>
</rss>

