<?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: Apply symbology to featureclass added via button addin in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002073#M5748</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can use geoprocessing function&amp;nbsp;ApplySymbologyFromLayer_management. More info about some details and code you can found here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/applysymbologyfromlayer-geoprocessing-tool/m-p/778081#M966" target="_self"&gt;https://community.esri.com/t5/arcgis-pro-sdk-questions/applysymbologyfromlayer-geoprocessing-tool/m-p/778081#M966&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/building-proper-syntax-for-importing-lyr-symbology-for-feature/m-p/817600#M2662" target="_self"&gt;https://community.esri.com/t5/arcgis-pro-sdk-questions/building-proper-syntax-for-importing-lyr-symbology-for-feature/m-p/817600#M2662&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another way is to create layer from lyrx file and change data connection (CIMDataConnection) to you featureclass source. You can find in Esri Pro samples.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 07:47:15 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2020-11-17T07:47:15Z</dc:date>
    <item>
      <title>Apply symbology to featureclass added via button addin</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1001904#M5744</link>
      <description>&lt;P&gt;Good Afternoon Everyone,&lt;/P&gt;&lt;P&gt;So I have a button created and it is adding a feature class to my map via a FileGeodatabaseConnectionPath. As seen below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            // Add this in your OnClick code-behind for the button
            if (MapView.Active?.Map == null) return;
            ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =&amp;gt;
            {
                // using the community sample dataset
                using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"U:\environmental\envgist.gdb"))))
                {
                    using (FeatureClass addFeatureClass = geodatabase.OpenDataset&amp;lt;FeatureClass&amp;gt;("counties"))
                    {
                        LayerFactory.Instance.CreateFeatureLayer(addFeatureClass, MapView.Active.Map, 0, "Counties");
                    }
                }
            });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What information do I need to add to apply symbology from a lyr/lyrx file to this feature class? The layer files are in a folder stored on the same location as the gdb.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help in the right direction is much appreciated.&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Derek Salinas&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 04:12:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1001904#M5744</guid>
      <dc:creator>DerekSalinas</dc:creator>
      <dc:date>2020-11-18T04:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Apply symbology to featureclass added via button addin</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002073#M5748</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can use geoprocessing function&amp;nbsp;ApplySymbologyFromLayer_management. More info about some details and code you can found here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/applysymbologyfromlayer-geoprocessing-tool/m-p/778081#M966" target="_self"&gt;https://community.esri.com/t5/arcgis-pro-sdk-questions/applysymbologyfromlayer-geoprocessing-tool/m-p/778081#M966&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/building-proper-syntax-for-importing-lyr-symbology-for-feature/m-p/817600#M2662" target="_self"&gt;https://community.esri.com/t5/arcgis-pro-sdk-questions/building-proper-syntax-for-importing-lyr-symbology-for-feature/m-p/817600#M2662&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another way is to create layer from lyrx file and change data connection (CIMDataConnection) to you featureclass source. You can find in Esri Pro samples.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 07:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002073#M5748</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2020-11-17T07:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Apply symbology to featureclass added via button addin</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002410#M5750</link>
      <description>&lt;P&gt;Good Evening Gin,&lt;/P&gt;&lt;P&gt;So in reply to your suggestion:&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;Another way is to create layer from lyrx file and change data connection (CIMDataConnection) to you featureclass source. You can find in Esri Pro samples."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Would that just mean I change my existing code above to add the lyr or lyrx file to the map via the button instead of a feature class?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 02:44:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002410#M5750</guid>
      <dc:creator>DerekSalinas</dc:creator>
      <dc:date>2020-11-18T02:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Apply symbology to featureclass added via button addin</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002443#M5751</link>
      <description>&lt;P&gt;Hi Derek,&lt;/P&gt;&lt;P&gt;If your lyr/ lyrx file contains path to your file gdb feature class then you need just to add lyr/lyrx file to map, otherwise&amp;nbsp; you need to change your existing code like this:&lt;/P&gt;&lt;P&gt;await QueuedTask.Run(() =&amp;gt; {&lt;/P&gt;&lt;P&gt;// add lyr/lyrx to map&lt;BR /&gt;var featureLayer = (FeatureLayer)LayerFactory.Instance.CreateLayer(new Uri(lyrFilePath), MapView.Active.Map, 0, "Counties");&lt;/P&gt;&lt;P&gt;CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();&lt;/P&gt;&lt;P&gt;CIMStandardDataConnection updatedDataConnection = null;&lt;BR /&gt;WorkspaceFactory wf = WorkspaceFactory.FileGDB;&lt;/P&gt;&lt;P&gt;var dbGdbConnection = new FileGeodatabaseConnectionPath(new Uri(@"U:\environmental\envgist.gdb"), UriKind.Absolute));&lt;BR /&gt;// provide a replace data connection method&lt;BR /&gt;updatedDataConnection = new CIMStandardDataConnection()&lt;BR /&gt;{&lt;BR /&gt;WorkspaceConnectionString = new Geodatabase(dbGdbConnection).GetConnectionString(),&lt;BR /&gt;WorkspaceFactory = wf,&lt;BR /&gt;Dataset = "counties",&lt;BR /&gt;DatasetType = esriDatasetType.esriDTFeatureClass&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;featureLayer.SetDataConnection(updatedDataConnection);&lt;/P&gt;&lt;P&gt;featureLayer.ClearDisplayCache();&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 06:12:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002443#M5751</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2020-11-18T06:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Apply symbology to featureclass added via button addin</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002693#M5752</link>
      <description>&lt;P&gt;Good Afternoon Gin!&lt;/P&gt;&lt;P&gt;Thanks so much for getting back to be so quick. That example worked out wonderfully! I did have to make a few edits to the code, as seen below.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;if (MapView.Active?.Map == null) return;
  QueuedTask.Run(() =&amp;gt;
  {            
  // add lyr/lyrx to map
  var featureLayer = (FeatureLayer)LayerFactory.Instance.CreateLayer(new 
                      Uri(@"layerpath"), MapView.Active.Map, 0, "TOC Name");

  CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();
  CIMStandardDataConnection updatedDataConnection = null;
  WorkspaceFactory wf = WorkspaceFactory.FileGDB;

// FileGeodatabaseConnectionPath does not contain a constructor that takes two arguments

     var dbGdbConnection = new FileGeodatabaseConnectionPath(new Uri(@"gdb 
     Path"));

// provide a replace data connection method

     updatedDataConnection = new CIMStandardDataConnection()
     {
       WorkspaceConnectionString = new 
       Geodatabase(dbGdbConnection).GetConnectionString(),
       WorkspaceFactory = wf,
       Dataset = "FeatureClassName",
       DatasetType = esriDatasetType.esriDTFeatureClass
      };

       featureLayer.SetDataConnection(updatedDataConnection);
       featureLayer.ClearDisplayCache();
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main correction was that FileGeodatabaseConnectionPath does not need to have a Uri type to be determined as it does not allow for more than one argument, which is the actual connection path. Maybe something different should be used there instead, but this seems to work all the same.&lt;/P&gt;&lt;P&gt;Once again, thank you for your help. It is very much appreciated.&lt;/P&gt;&lt;P&gt;-Derek Salinas&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 20:31:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/apply-symbology-to-featureclass-added-via-button/m-p/1002693#M5752</guid>
      <dc:creator>DerekSalinas</dc:creator>
      <dc:date>2020-11-18T20:31:42Z</dc:date>
    </item>
  </channel>
</rss>

