Hi all,
I'm struggling with an issue which I think is a bug in arcpy. I'm using AddSymbologyFromLayer_management to apply the symbology from a reference layerfile (yes, an actual layerFILE, not a layer within the mxd) to a newly created polygon shapefile which is displayed as a layer. This works fine, even when I change the field the symbology shall be based on. However, when I also change the class breaks (I use GRADUATED_COLORS here), the outlines, which are set to "No color" in the reference layerfile, are set back to default, which means some kind of grey with 0.4pt width. This behaviour only occurs when I change the class breaks via code, if I keep them as they are, everything is fine.
This is what I basically do within the code:
<SPAN class="comment token"># get reference layer</SPAN>
ref_lyr_file <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'styles'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'graduated_colors_reference_style.lyr'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># get newly created layer</SPAN>
new_lyr <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> lyr<SPAN class="punctuation token">,</SPAN> mapDF<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># import symbology from reference layer-file</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>ApplySymbologyFromLayer_management<SPAN class="punctuation token">(</SPAN>new_lyr<SPAN class="punctuation token">,</SPAN> ref_lyr_file<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># set value field</SPAN>
new_lyr<SPAN class="punctuation token">.</SPAN>symbology<SPAN class="punctuation token">.</SPAN>valueField <SPAN class="operator token">=</SPAN> draw_param_dict<SPAN class="punctuation token">[</SPAN>draw_parameter<SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># reclassify values</SPAN>
new_lyr<SPAN class="punctuation token">.</SPAN>symbology<SPAN class="punctuation token">.</SPAN>reclassify<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
breaks <SPAN class="operator token">=</SPAN> new_lyr<SPAN class="punctuation token">.</SPAN>symbology<SPAN class="punctuation token">.</SPAN>classBreakValues
<SPAN class="comment token"># round values nicely as new class breaks</SPAN>
lenMin <SPAN class="operator token">=</SPAN> len<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>int<SPAN class="punctuation token">(</SPAN>breaks<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
new_breaks <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>int<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>round<SPAN class="punctuation token">(</SPAN>b <SPAN class="operator token">/</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">10</SPAN> <SPAN class="operator token">**</SPAN> lenMin<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">10</SPAN> <SPAN class="operator token">**</SPAN> lenMin<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> b <SPAN class="keyword token">in</SPAN> breaks<SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># update map document</SPAN>
new_lyr<SPAN class="punctuation token">.</SPAN>symbology<SPAN class="punctuation token">.</SPAN>classBreakValues <SPAN class="operator token">=</SPAN> new_breaks
arcpy<SPAN class="punctuation token">.</SPAN>RefreshTOC<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>RefreshActiveView<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
How I create the new breaks is not important, so you can skip this section. The thing is: the polygon outlines are set back to the default color ONLY AFTER applying new class break values.
Does anyone know how to get around this?
Thanks for any help 