<?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: How to save layer symbology as text and apply it later in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546830#M12158</link>
    <description>&lt;P&gt;Lyrx is a pure text solution - xml:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "type" : "CIMLayerDocument",
  "version" : "1.1.0",
  "build" : 3219,
  "layers" : [
    "CIMPATH=map/meteoritesuk.xml"
  ],
  "layerDefinitions" : [
    {
      "type" : "CIMFeatureLayer",
      "name" : "MeteoritesUK",
      "uRI" : "CIMPATH=map/meteoritesuk.xml",
      "sourceModifiedTime" : {
        "type" : "TimeInstant"
      },
      "description" : "MeteoritesUK",
      "layerElevation" : {
        "type" : "CIMLayerElevationSurface",
        "mapElevationID" : "{D9EFA120-D6D6-4152-8711-6765DCCF05C5}"
      },
      "expanded" : true,
      "layerType" : "Operational",
      "showLegends" : true,
      "visibility" : true,
      "displayCacheType" : "Permanent",
      "maxDisplayCacheAge" : 5,
      "showPopups" : true,
      "autoGenerateFeatureTemplates" : true,
      "featureTable" : {
        "type" : "CIMFeatureTable",
        "displayField" : "NAME",
        "editable" : true,
        "dataConnection" : {
          "type" : "CIMStandardDataConnection",
          "workspaceConnectionString" : "DATABASE=.\\SDK.gdb",
          "workspaceFactory" : "FileGDB",
          "dataset" : "MeteoritesUK",
          "datasetType" : "esriDTFeatureClass"
        },
        "studyAreaSpatialRel" : "esriSpatialRelUndefined",
        "searchOrder" : "esriSearchOrderSpatial"
      },
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Oct 2024 05:59:40 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2024-10-09T05:59:40Z</dc:date>
    <item>
      <title>How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1545989#M12148</link>
      <description>&lt;P&gt;I have been trying to save the CIMFeatureLayer, Renderer, Symbol as text and load it later. But all failed with error like can not create instance of abstract class.&lt;/P&gt;&lt;P&gt;Here is an example code with CIMFeatureLayer:&lt;/P&gt;&lt;P&gt;var cimLayer = mapLayer.GetDefinition() as CIMFeatureLayer;&lt;BR /&gt;String xmlSymbology = JsonConvert.SerializeObject(cimLayer);&lt;BR /&gt;CIMFeatureLayer layer2 = JsonConvert.DeserializeObject&amp;lt;CIMFeatureLayer&amp;gt;(xmlSymbology);&lt;BR /&gt;mapLayer.SetDefinition(layer2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the best practice for this task with ArcGIS Pro SDK?&lt;/P&gt;</description>
      <pubDate>Sun, 06 Oct 2024 22:51:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1545989#M12148</guid>
      <dc:creator>zhangjinzhou</dc:creator>
      <dc:date>2024-10-06T22:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546044#M12149</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would recommend you use Esri lyrx format to save layer and load it later. More info &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic26526.html" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 06:22:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546044#M12149</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-10-07T06:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546591#M12155</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for the reply! For my case, a pure text solution would be way better as it doesn't require change of existing addin architecture as all of other info are saved as a xml. In ArcMap, we had this solution&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Save renderer as hex
hex = SaveToHex((ESRI.ArcGIS.esriSystem.IPersistStream)(((ESRI.ArcGIS.Carto.IGeoFeatureLayer)layerObj).Renderer));

// Load renderer from hex
renderer = LoadFromHex(data);
((ESRI.ArcGIS.Carto.IGeoFeatureLayer)layerObj).Renderer = (ESRI.ArcGIS.Carto.IFeatureRenderer)renderer;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an equivalent class of IGeoFeatureLayer in ArcGIS Pro SDK?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 15:25:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546591#M12155</guid>
      <dc:creator>zhangjinzhou</dc:creator>
      <dc:date>2024-10-08T15:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546830#M12158</link>
      <description>&lt;P&gt;Lyrx is a pure text solution - xml:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "type" : "CIMLayerDocument",
  "version" : "1.1.0",
  "build" : 3219,
  "layers" : [
    "CIMPATH=map/meteoritesuk.xml"
  ],
  "layerDefinitions" : [
    {
      "type" : "CIMFeatureLayer",
      "name" : "MeteoritesUK",
      "uRI" : "CIMPATH=map/meteoritesuk.xml",
      "sourceModifiedTime" : {
        "type" : "TimeInstant"
      },
      "description" : "MeteoritesUK",
      "layerElevation" : {
        "type" : "CIMLayerElevationSurface",
        "mapElevationID" : "{D9EFA120-D6D6-4152-8711-6765DCCF05C5}"
      },
      "expanded" : true,
      "layerType" : "Operational",
      "showLegends" : true,
      "visibility" : true,
      "displayCacheType" : "Permanent",
      "maxDisplayCacheAge" : 5,
      "showPopups" : true,
      "autoGenerateFeatureTemplates" : true,
      "featureTable" : {
        "type" : "CIMFeatureTable",
        "displayField" : "NAME",
        "editable" : true,
        "dataConnection" : {
          "type" : "CIMStandardDataConnection",
          "workspaceConnectionString" : "DATABASE=.\\SDK.gdb",
          "workspaceFactory" : "FileGDB",
          "dataset" : "MeteoritesUK",
          "datasetType" : "esriDTFeatureClass"
        },
        "studyAreaSpatialRel" : "esriSpatialRelUndefined",
        "searchOrder" : "esriSearchOrderSpatial"
      },
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 05:59:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1546830#M12158</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-10-09T05:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1547194#M12160</link>
      <description>&lt;P&gt;That's wonderful! Do you have any sample code for this? Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 17:33:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1547194#M12160</guid>
      <dc:creator>zhangjinzhou</dc:creator>
      <dc:date>2024-10-09T17:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1547305#M12162</link>
      <description>&lt;P&gt;Savint to lyrx:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;LayerDocument layerDocument = new LayerDocument(layer);
layerDocument.Save(@"c:\Data\MyLayerDocument.lyrx");&lt;/LI-CODE&gt;
&lt;P&gt;Opening from lyrx:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;//Note: Call within QueuedTask.Run()
var layerDoc = new LayerDocument(@"E:\Data\SDK\Default2DPointSymbols.lyrx");
var createParams = new LayerCreationParams(layerDoc.GetCIMLayerDocument());
LayerFactory.Instance.CreateLayer&amp;lt;FeatureLayer&amp;gt;(createParams, MapView.Active.Map);&lt;/LI-CODE&gt;
&lt;P&gt;Modifying existing layer symbology using lyrx:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;        private static async Task ModifyLayerSymbologyFromLyrFileAsync(FeatureLayer featureLayer, string layerFile)
        {
            await QueuedTask.Run(() =&amp;gt; {
                //Does layer file exist
                if (!System.IO.File.Exists(layerFile))
                    return;

                //Get the Layer Document from the lyrx file
                var lyrDocFromLyrxFile = new LayerDocument(layerFile);
                var cimLyrDoc = lyrDocFromLyrxFile.GetCIMLayerDocument();

                //Get the renderer from the layer file
                var rendererFromLayerFile = ((CIMFeatureLayer)cimLyrDoc.LayerDefinitions[0]).Renderer as CIMSimpleRenderer;

                if (rendererFromLayerFile == null)
                    return;

                //Apply the renderer to the feature layer
                featureLayer?.SetRenderer(rendererFromLayerFile);

            });
        }

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 19:40:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1547305#M12162</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-10-09T19:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to save layer symbology as text and apply it later</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1547606#M12164</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 14:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-save-layer-symbology-as-text-and-apply-it/m-p/1547606#M12164</guid>
      <dc:creator>zhangjinzhou</dc:creator>
      <dc:date>2024-10-10T14:43:44Z</dc:date>
    </item>
  </channel>
</rss>

