<?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 Code for copying pie chart symbology using ArcPy not working in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032795#M38130</link>
    <description>&lt;P&gt;This is a question relating to the use of ArcPy in ArcGIS Pro 2.5.1. In essence, I am trying to write a piece code to copy the symbology from one pie chart to another. Both pie charts use the same fields and their underlying tables have exactly the same columns. It is very important that the size of the pie chart is determined by the value of one specific field. I already contacted ESRI, who told me that it is not possible to set the size of a pie chart by field value when the symbolized layer consists of a join between two layers (which is the case here). Hence, I wrote a piece of code to do the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Export the join layer to a gdb feature class&lt;/LI&gt;&lt;LI&gt;Load this feature class into the correct map inside the aprx file (it is now no longer a 'join' layer, hence solving the issue)&lt;/LI&gt;&lt;LI&gt;Apply the symbology from an example symbology layer to this newly imported layer&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The code is shown below. It produces no errors. The pie chart layer is correctly imported. However, the ApplySymbologyFromLayer does not seem to do anything. The symbology_example layer from which the symbology should be copied, definitely has the correct symbology.&lt;/P&gt;&lt;P&gt;Can anyone help me figure out why the code is running without errors, but not symbolizing my layer correctly? I have also tries exporting the layer as a layer file, then importing it again. However, this gives me an error when trying to copy the symbology, as there is a type mismatch between goal and source layer.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="hljs-comment"&gt;# Assign input parameters to variables&lt;/SPAN&gt;

name_GDB = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;)
arcpy.env.workspace = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;)
aprx = arcpy.mp.ArcGISProject(&lt;SPAN class="hljs-string"&gt;"CURRENT"&lt;/SPAN&gt;)
arcpy.management.CreateFileGDB(&lt;SPAN class="hljs-string"&gt;f"&lt;SPAN class="hljs-subst"&gt;{arcpy.env.workspace}&lt;/SPAN&gt;"&lt;/SPAN&gt;,  name_GDB)

&lt;SPAN class="hljs-comment"&gt;# make a map object ("piechart_map" refers to the map in which the pie charts are located)&lt;/SPAN&gt;

versch = (aprx.listMaps(&lt;SPAN class="hljs-string"&gt;"piechart_map"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;])

&lt;SPAN class="hljs-comment"&gt;# Bullet 1 in list : write the joined layers to a gdb feature class&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;# "Pie_Charts" is a lyr containing 3 individual sublayers to be formatted as pie charts, &lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;# for the sake of argument, I reduced the code so that it only looks at one of these 3 &lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;# (code is analogous for 2 other pie charts)&lt;/SPAN&gt;
out_path = &lt;SPAN class="hljs-string"&gt;f"&lt;SPAN class="hljs-subst"&gt;{arcpy.env.workspace}&lt;/SPAN&gt;\\&lt;SPAN class="hljs-subst"&gt;{name_GDB}&lt;/SPAN&gt;.gdb"&lt;/SPAN&gt;    
versch_lyr = versch.listLayers(&lt;SPAN class="hljs-string"&gt;"Pie_Charts"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].listLayers()
Pie_Chart = arcpy.conversion.FeatureClassToFeatureClass(versch_lyr[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;], out_path, &lt;SPAN class="hljs-string"&gt;"Pie_Chart"&lt;/SPAN&gt;)


&lt;SPAN class="hljs-comment"&gt;# Bullet 2 in list :add the layer from gdb to map s.t. it can be symbolized correctly&lt;/SPAN&gt;

path_PieChart = &lt;SPAN class="hljs-string"&gt;f"&lt;SPAN class="hljs-subst"&gt;{out_path}&lt;/SPAN&gt;\\Pie_Chart"&lt;/SPAN&gt; &lt;SPAN class="hljs-comment"&gt;#path to feature class&lt;/SPAN&gt;
versch.addDataFromPath(path_PieChart) &lt;SPAN class="hljs-comment"&gt;#load feature class&lt;/SPAN&gt;

&lt;SPAN class="hljs-comment"&gt;# Bullet 3 in list : Transfer the symbology from the example lyr (Symbology_example) to the imported &lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;# layer (Pie Chart)&lt;/SPAN&gt;

symbologyFields = [[&lt;SPAN class="hljs-string"&gt;"VALUE_FIELD"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"ZC_na_V"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"ZC_na_V"&lt;/SPAN&gt;],
                   [&lt;SPAN class="hljs-string"&gt;"VALUE_FIELD"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_nsch"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_nsch"&lt;/SPAN&gt;], 
                   [&lt;SPAN class="hljs-string"&gt;"VALUE_FIELD"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_sch"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_sch"&lt;/SPAN&gt;]]
arcpy.management.ApplySymbologyFromLayer(versch.listLayers(&lt;SPAN class="hljs-string"&gt;"Pie_Chart"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;], versch.listLayers(&lt;SPAN class="hljs-string"&gt;"Pie_Charts"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].listLayers(&lt;SPAN class="hljs-string"&gt;"Symbology_example"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;],symbologyFields)&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Mar 2021 10:14:35 GMT</pubDate>
    <dc:creator>AntonDhooge</dc:creator>
    <dc:date>2021-03-04T10:14:35Z</dc:date>
    <item>
      <title>Code for copying pie chart symbology using ArcPy not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032795#M38130</link>
      <description>&lt;P&gt;This is a question relating to the use of ArcPy in ArcGIS Pro 2.5.1. In essence, I am trying to write a piece code to copy the symbology from one pie chart to another. Both pie charts use the same fields and their underlying tables have exactly the same columns. It is very important that the size of the pie chart is determined by the value of one specific field. I already contacted ESRI, who told me that it is not possible to set the size of a pie chart by field value when the symbolized layer consists of a join between two layers (which is the case here). Hence, I wrote a piece of code to do the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Export the join layer to a gdb feature class&lt;/LI&gt;&lt;LI&gt;Load this feature class into the correct map inside the aprx file (it is now no longer a 'join' layer, hence solving the issue)&lt;/LI&gt;&lt;LI&gt;Apply the symbology from an example symbology layer to this newly imported layer&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The code is shown below. It produces no errors. The pie chart layer is correctly imported. However, the ApplySymbologyFromLayer does not seem to do anything. The symbology_example layer from which the symbology should be copied, definitely has the correct symbology.&lt;/P&gt;&lt;P&gt;Can anyone help me figure out why the code is running without errors, but not symbolizing my layer correctly? I have also tries exporting the layer as a layer file, then importing it again. However, this gives me an error when trying to copy the symbology, as there is a type mismatch between goal and source layer.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="hljs-comment"&gt;# Assign input parameters to variables&lt;/SPAN&gt;

name_GDB = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;)
arcpy.env.workspace = arcpy.GetParameterAsText(&lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;)
aprx = arcpy.mp.ArcGISProject(&lt;SPAN class="hljs-string"&gt;"CURRENT"&lt;/SPAN&gt;)
arcpy.management.CreateFileGDB(&lt;SPAN class="hljs-string"&gt;f"&lt;SPAN class="hljs-subst"&gt;{arcpy.env.workspace}&lt;/SPAN&gt;"&lt;/SPAN&gt;,  name_GDB)

&lt;SPAN class="hljs-comment"&gt;# make a map object ("piechart_map" refers to the map in which the pie charts are located)&lt;/SPAN&gt;

versch = (aprx.listMaps(&lt;SPAN class="hljs-string"&gt;"piechart_map"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;])

&lt;SPAN class="hljs-comment"&gt;# Bullet 1 in list : write the joined layers to a gdb feature class&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;# "Pie_Charts" is a lyr containing 3 individual sublayers to be formatted as pie charts, &lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;# for the sake of argument, I reduced the code so that it only looks at one of these 3 &lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;# (code is analogous for 2 other pie charts)&lt;/SPAN&gt;
out_path = &lt;SPAN class="hljs-string"&gt;f"&lt;SPAN class="hljs-subst"&gt;{arcpy.env.workspace}&lt;/SPAN&gt;\\&lt;SPAN class="hljs-subst"&gt;{name_GDB}&lt;/SPAN&gt;.gdb"&lt;/SPAN&gt;    
versch_lyr = versch.listLayers(&lt;SPAN class="hljs-string"&gt;"Pie_Charts"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].listLayers()
Pie_Chart = arcpy.conversion.FeatureClassToFeatureClass(versch_lyr[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;], out_path, &lt;SPAN class="hljs-string"&gt;"Pie_Chart"&lt;/SPAN&gt;)


&lt;SPAN class="hljs-comment"&gt;# Bullet 2 in list :add the layer from gdb to map s.t. it can be symbolized correctly&lt;/SPAN&gt;

path_PieChart = &lt;SPAN class="hljs-string"&gt;f"&lt;SPAN class="hljs-subst"&gt;{out_path}&lt;/SPAN&gt;\\Pie_Chart"&lt;/SPAN&gt; &lt;SPAN class="hljs-comment"&gt;#path to feature class&lt;/SPAN&gt;
versch.addDataFromPath(path_PieChart) &lt;SPAN class="hljs-comment"&gt;#load feature class&lt;/SPAN&gt;

&lt;SPAN class="hljs-comment"&gt;# Bullet 3 in list : Transfer the symbology from the example lyr (Symbology_example) to the imported &lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;# layer (Pie Chart)&lt;/SPAN&gt;

symbologyFields = [[&lt;SPAN class="hljs-string"&gt;"VALUE_FIELD"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"ZC_na_V"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"ZC_na_V"&lt;/SPAN&gt;],
                   [&lt;SPAN class="hljs-string"&gt;"VALUE_FIELD"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_nsch"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_nsch"&lt;/SPAN&gt;], 
                   [&lt;SPAN class="hljs-string"&gt;"VALUE_FIELD"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_sch"&lt;/SPAN&gt;,&lt;SPAN class="hljs-string"&gt;"V_sch"&lt;/SPAN&gt;]]
arcpy.management.ApplySymbologyFromLayer(versch.listLayers(&lt;SPAN class="hljs-string"&gt;"Pie_Chart"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;], versch.listLayers(&lt;SPAN class="hljs-string"&gt;"Pie_Charts"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].listLayers(&lt;SPAN class="hljs-string"&gt;"Symbology_example"&lt;/SPAN&gt;)[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;],symbologyFields)&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 10:14:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032795#M38130</guid>
      <dc:creator>AntonDhooge</dc:creator>
      <dc:date>2021-03-04T10:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Code for copying pie chart symbology using ArcPy not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032808#M38132</link>
      <description>&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDExNjUyNw==" target="_blank" rel="noopener"&gt;BUG-000116527: ApplySymbologyFromLayer in a Python script in ArcGIS.. (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEwODQ5Nw==" target="_blank" rel="noopener"&gt;BUG-000108497: Running the Apply Layer Symbology tool as a script i.. (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Not in current production plan&amp;nbsp; (not sure why, but have a look-see)&lt;/P&gt;&lt;P&gt;Alternate solution :&amp;nbsp; Close and reopen the project&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 11:41:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032808#M38132</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-03-04T11:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Code for copying pie chart symbology using ArcPy not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032811#M38133</link>
      <description>&lt;P&gt;Dan,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for you reply. I have tried closing and reopening the project on multiple occasions, which did not fix my issue.&lt;/P&gt;&lt;P&gt;Kr,&lt;BR /&gt;Anton&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 11:58:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032811#M38133</guid>
      <dc:creator>AntonDhooge</dc:creator>
      <dc:date>2021-03-04T11:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Code for copying pie chart symbology using ArcPy not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032817#M38135</link>
      <description>&lt;P&gt;&lt;EM&gt;Duplicate of BUG-000108497. Similar to another apply symbology tool bug. Will put this as a test case for when the issue is completed.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;File your own case and Subscribe to the listed bugs, there may be wider issues and the number of people using pie chart symbology in python code is probably not a huge target audience, so "issues" can slide unnoticed for many update.&lt;/P&gt;&lt;P&gt;On that note, check the release notes for 2.7 and 2.6 which lists the bug fixes and enhancements&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/get-started/release-notes.htm" target="_blank"&gt;Release notes for ArcGIS Pro 2.7—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;in case the issues is only indirectly related to ApplySymbologyFromLayer&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 12:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/code-for-copying-pie-chart-symbology-using-arcpy/m-p/1032817#M38135</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-03-04T12:14:10Z</dc:date>
    </item>
  </channel>
</rss>

