What is the syntax to retrieve all layers' set minimum scale ?
<SPAN class="keyword token">for</SPAN> layer <SPAN class="keyword token">in</SPAN> layers<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> layer<SPAN class="punctuation token">.</SPAN>isFeatureLayer<SPAN class="punctuation token">:</SPAN> lyr_source <SPAN class="operator token">=</SPAN> layer<SPAN class="punctuation token">.</SPAN>dataSource lyr_name <SPAN class="operator token">=</SPAN> layer<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">.</SPAN>encode<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"utf8"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"replace"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> fullpath <SPAN class="operator token">+</SPAN> <SPAN class="string token">" "</SPAN> <SPAN class="operator token">+</SPAN> lyr_source <SPAN class="operator token">+</SPAN> <SPAN class="string token">" "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>minScale<SPAN class="punctuation token">)</SPAN> scale <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>layer<SPAN class="punctuation token">.</SPAN>minScale<SPAN class="punctuation token">]</SPAN> <SPAN class="comment token"># Write to Excel</SPAN> b <SPAN class="operator token">=</SPAN> fullpath<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'\\'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> lyr_source<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'\\'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> scale writer<SPAN class="punctuation token">.</SPAN>writerow<SPAN class="punctuation token">(</SPAN>b<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>
Thanks, everyone I arrived at my final solution.
Perfect, I arrived at the same.
Make sense, set the mxd and loop layers.
I will add this to an existing script that write data to csv.
Thanks
Try:
mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CURRENT"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> lyr <SPAN class="keyword token">in</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><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># to read minScale</SPAN> <SPAN class="keyword token">print</SPAN> lyr<SPAN class="punctuation token">.</SPAN>minScale <SPAN class="comment token"># to set minScale</SPAN> lyr<SPAN class="punctuation token">.</SPAN>minScale <SPAN class="operator token">=</SPAN> <SPAN class="number token">500.0</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I know that it can be done, documentation is lacking.
The arcpy help is your best bet... this is the layer section
and from there, nothing too exciting ... maybe... mylayer.minScale if it is property
Provides the ability to set or get the layer's minimum scale threshold.
As for arcpy.... bookmark the start of its menu tree... Arcpy ... , Dr Google isn't very good at tracking down all the properties and methods
I haven't tried anything yet and yes you are correct as I did not have any luck searching the internet to achieve this.
not sure what you mean beyond it returning a double (number). Are you wanting to cycle through all the layers and return the minScale for each? Did you try something and it didn't work?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.