Hi all. I'm in trouble with the SaveToLayerFile_management function in a python script for arcgis pro 2.1.2. The script is setting a symbology that works but happens to not beeing saved on disk. I mean the lyrx file is done but doesn't contain the symbology. I've tried many changes in vain. The code below works properly on the python console however. For info, I changed here somes values initially gotten with GetParameterAsText.
Ws<SPAN class="operator token">=</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace
Mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Current"</SPAN><SPAN class="punctuation token">)</SPAN>
MapPath <SPAN class="operator token">=</SPAN> Mxd<SPAN class="punctuation token">.</SPAN>filePath
ActMap <SPAN class="operator token">=</SPAN> Mxd<SPAN class="punctuation token">.</SPAN>activeMap
LyrName <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Benzene'</SPAN>
SeuilsNb <SPAN class="operator token">=</SPAN> <SPAN class="number token">2</SPAN>
Seuils <SPAN class="operator token">=</SPAN> <SPAN class="string token">"10;580"</SPAN> <SPAN class="comment token">#string vers list</SPAN>
fileName <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>basename<SPAN class="punctuation token">(</SPAN>MapPath<SPAN class="punctuation token">)</SPAN>
fileNameLen <SPAN class="operator token">=</SPAN> len<SPAN class="punctuation token">(</SPAN>fileName<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="number token">1</SPAN>
Ws <SPAN class="operator token">=</SPAN> MapPath<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="operator token">-</SPAN>fileNameLen<SPAN class="punctuation token">]</SPAN>
in_layer <SPAN class="operator token">=</SPAN> ActMap<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN>LyrName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
LayerSource <SPAN class="operator token">=</SPAN> in_layer<SPAN class="punctuation token">.</SPAN>dataSource
TargetFolder <SPAN class="operator token">=</SPAN> <SPAN class="string token">"J:\\00-Template-job_Oct2017\\900_CAD_GIS\\Lyr"</SPAN>
Labels <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> Seuil <SPAN class="keyword token">in</SPAN> Seuils<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> Seuil <SPAN class="operator token">==</SPAN> Seuils<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN>
Labels<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Inférieur à "</SPAN> <SPAN class="operator token">+</SPAN> Seuil<SPAN class="punctuation token">)</SPAN>
BorneInf <SPAN class="operator token">=</SPAN> Seuil
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
Labels<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>BorneInf <SPAN class="operator token">+</SPAN> <SPAN class="string token">" à "</SPAN> <SPAN class="operator token">+</SPAN> Seuil<SPAN class="punctuation token">)</SPAN>
BorneInf <SPAN class="operator token">=</SPAN> Seuil
Symbologie <SPAN class="operator token">=</SPAN> in_layer<SPAN class="punctuation token">.</SPAN>symbology
Symbologie<SPAN class="punctuation token">.</SPAN>updateRenderer<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'GraduatedColorsRenderer'</SPAN><SPAN class="punctuation token">)</SPAN>
Symbologie<SPAN class="punctuation token">.</SPAN>renderer<SPAN class="punctuation token">.</SPAN>classificationField <SPAN class="operator token">=</SPAN> <SPAN class="string token">'result_value_atof'</SPAN>
Symbologie<SPAN class="punctuation token">.</SPAN>renderer<SPAN class="punctuation token">.</SPAN>breakCount <SPAN class="operator token">=</SPAN> SeuilsNb
i <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
<SPAN class="keyword token">for</SPAN> bc <SPAN class="keyword token">in</SPAN> Symbologie<SPAN class="punctuation token">.</SPAN>renderer<SPAN class="punctuation token">.</SPAN>classBreaks<SPAN class="punctuation token">:</SPAN>
bc<SPAN class="punctuation token">.</SPAN>upperBound <SPAN class="operator token">=</SPAN> float<SPAN class="punctuation token">(</SPAN>Seuils<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
bc<SPAN class="punctuation token">.</SPAN>label <SPAN class="operator token">=</SPAN> Labels<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN>
i <SPAN class="operator token">=</SPAN><SPAN class="operator token">+</SPAN><SPAN class="number token">1</SPAN>
in_layer<SPAN class="punctuation token">.</SPAN>symbology <SPAN class="operator token">=</SPAN> Symbologie
arcpy<SPAN class="punctuation token">.</SPAN>SaveToLayerFile_management<SPAN class="punctuation token">(</SPAN>LyrName<SPAN class="punctuation token">,</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>TargetFolder<SPAN class="punctuation token">,</SPAN> LyrName <SPAN class="operator token">+</SPAN> <SPAN class="string token">".lyrx"</SPAN><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></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>
Thanks in advance for the help!