<?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: Having difficulty in rendering symbology layer file (.lyr) using ArcGIS Pro SDK in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1090747#M7054</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/145101"&gt;@CharlesMacleod&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/9021"&gt;@UmaHarano&lt;/a&gt;&amp;nbsp;, I tried using&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;LayerDocument and&amp;nbsp;CIMUniqueValueClass and it worked pretty fine for me. Thanks for your time and help!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Shabina&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 10:26:53 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-08-20T10:26:53Z</dc:date>
    <item>
      <title>Having difficulty in rendering symbology layer file (.lyr) using ArcGIS Pro SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1088821#M7030</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are connecting to SDE with ArcGIS Pro SDK to retrieve the polygon layer. We also have a symbology file for the same polygon layer.&lt;/P&gt;&lt;P&gt;So, when using the symbology layer to render the polygon feature layer, we're having trouble with settings some of its properties.&amp;nbsp;In symbology layer we have a Boolean field "HasAlignmentSheet" which determines the color&amp;nbsp; of polygon features(This field is not present within the polygon data layer).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Can anyone please provide the basic sample to use the symbology layer's renderer with the feature layer.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;We have tried and currently we are getting the below output.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShabinaBano_3-1628856937275.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20806iCC1E5A265B29CF45/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShabinaBano_3-1628856937275.png" alt="ShabinaBano_3-1628856937275.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The code we have used to renderer this :-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;//Connecting to geodatabase to get the polygon layer&lt;BR /&gt;Geodatabase geodatabase = new Geodatabase("Database Connection Properties")&lt;BR /&gt;featureClassAsTable = geodatabase.OpenDataset&amp;lt;Table&amp;gt;("Polygon Layer");&lt;BR /&gt;featureClassOpenedAsTable = featureClassAsTable as FeatureClass;&lt;/P&gt;&lt;P&gt;var layer = MapGlobal.Instance.map.Layers[1] as FeatureLayer;&lt;BR /&gt;List&amp;lt;FeatureLayer&amp;gt; featLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().ToList();&lt;BR /&gt;FeatureLayer inputLayer = featLayers[1];&lt;BR /&gt;string symbologyLayer = @"C:\ drive\A_SHEET_INDEX.lyr";&lt;BR /&gt;&lt;BR /&gt;// using GP tool to add the symbology layer to the polygon layer&lt;BR /&gt;var parameters = Geoprocessing.MakeValueArray(inputLayer, symbologyLayer);&lt;BR /&gt;IGPResult pGPresult = await Geoprocessing.ExecuteToolAsync("management.ApplySymbologyFromLayer", parameters);&lt;/P&gt;&lt;P&gt;CIMUniqueValueRenderer UniqueValueRenderer = layer2.GetRenderer() as CIMUniqueValueRenderer;&lt;/P&gt;&lt;P&gt;// getting the two symbol from the symbology layer based on the field property "HasAlignmentSheet"&lt;BR /&gt;var hasNoAlignment = UniqueValueRenderer.Groups[0].Classes.Where(x =&amp;gt; x.Label == "No Alignment Sheet").Select(y =&amp;gt; y.Symbol).FirstOrDefault();&lt;BR /&gt;var hasAlignment = UniqueValueRenderer.Groups[0].Classes.Where(x =&amp;gt; x.Label == "Has Alignment Sheet").Select(y =&amp;gt; y.Symbol).FirstOrDefault();&lt;BR /&gt;&lt;BR /&gt;// making changes in the renderer for the polygon layer&lt;BR /&gt;UniqueValueRenderer.DefaultSymbol = hasNoAlignment;&lt;BR /&gt;UniqueValueRenderer.UseDefaultSymbol = true;&lt;/P&gt;&lt;P&gt;//Setting the renderer for the polygon layer&lt;BR /&gt;layer2.SetRenderer(UniqueValueRenderer);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;We are looking for the following output/ result&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShabinaBano_4-1628857078868.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20807iC58586965E2FC8E2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShabinaBano_4-1628857078868.png" alt="ShabinaBano_4-1628857078868.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We want to remove the "all other values" from the symbology section as well as render the polygon features based on the&amp;nbsp; Boolean field "HasAlignmentSheet" (we are fetching from&amp;nbsp; the symbology layer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 12:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1088821#M7030</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-13T12:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty in rendering symbology layer file (.lyr) using ArcGIS Pro SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1089337#M7035</link>
      <description>&lt;P&gt;Try using a &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic26515.html" target="_self"&gt;LayerDocument&lt;/A&gt; instead.&lt;/P&gt;&lt;P&gt;This snippet shows the workflow to follow:&amp;nbsp;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-MapAuthoring#apply-symbology-to-a-layer-from-a-layer-file" target="_self"&gt;apply-symbology-to-a-layer-from-a-layer-file&lt;/A&gt;&amp;nbsp;. Some more information can be found here:&amp;nbsp;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Map-Authoring#layer-files-and-layer-packages" target="_self"&gt;ProConcepts-Map-Authoring#layer-files-and-layer-packages&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 16:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1089337#M7035</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2021-08-16T16:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty in rendering symbology layer file (.lyr) using ArcGIS Pro SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1089358#M7036</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Instead of using the GP Tool to apply the symbology from lyrx file, I recommend using LayerDocuments.&lt;/P&gt;&lt;P&gt;You can apply symbology to a feature layer from an existing lyrx file by accessing the CIMFeatureLayer from the LayerDocument.&lt;/P&gt;&lt;P&gt;Here is a code snippet to help with this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault();
QueuedTask.Run( () =&amp;gt; {
//Create a LayerDocument from a Lyrx file.
var layerDocument = new LayerDocument(@"C:\Temp\Symbology.lyrx");
//Get the renderer used in the lyrx file using the CIMLayerDocument
//This lyrx file has a unique value renderer
var cimFeaturLayer = layerDocument.GetCIMLayerDocument().LayerDefinitions[0] as CIMFeatureLayer;
var rendererToUse = cimFeaturLayer.Renderer as CIMUniqueValueRenderer;
//You can make your changes to the renderer now
//rendererToUse.DefaultSymbol = ...
//Set the renderer to the feature layer
featureLayer.SetRenderer(rendererToUse);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try your workflow with this and see if you get the expected result? Please let me know if you get stuck.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Uma&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 17:51:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1089358#M7036</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2021-08-16T17:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty in rendering symbology layer file (.lyr) using ArcGIS Pro SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1090747#M7054</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/145101"&gt;@CharlesMacleod&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/9021"&gt;@UmaHarano&lt;/a&gt;&amp;nbsp;, I tried using&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;LayerDocument and&amp;nbsp;CIMUniqueValueClass and it worked pretty fine for me. Thanks for your time and help!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Shabina&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 10:26:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/having-difficulty-in-rendering-symbology-layer/m-p/1090747#M7054</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-20T10:26:53Z</dc:date>
    </item>
  </channel>
</rss>

