<?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: Error: Error in setting scale value; Using ConvertWebMaptoMapDocument/arcpy.mapping in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-error-in-setting-scale-value-using/m-p/1010932#M59321</link>
    <description>&lt;P data-unlink="true"&gt;I did more searching and tried to understand some of the posts better. I used &lt;A href="https://community.esri.com/t5/python-questions/dataframe-scale-problem-when-map-created-through/td-p/326699" target="_self"&gt;this&lt;/A&gt;&amp;nbsp;post and Dev Tools. I was having trouble with reading it because of the one-line python script, but I finally got through it.&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I added my piece before the&lt;/P&gt;&lt;P data-unlink="true"&gt;result = arcpy.mapping.ConvertWebMapToMapDocument(Web_Map_as_JSON, templateMxd,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r'C:\temp\notes.gdb')&lt;/P&gt;&lt;P data-unlink="true"&gt;section, which is where the web map is converted to the document.&lt;/P&gt;&lt;P data-unlink="true"&gt;Here's my addition:&lt;/P&gt;&lt;P data-unlink="true"&gt;#Extra parameter - Scale&lt;BR /&gt;Scale = float(6000)&lt;BR /&gt;# modify Web_Map_as_JSON so that the web map scale matches the scale provided.&lt;BR /&gt;Web_Map_Dict = json.loads(Web_Map_as_JSON)&lt;BR /&gt;Web_Map_Dict["mapOptions"]["scale"] = Scale&lt;BR /&gt;Web_Map_as_JSON = json.dumps(Web_Map_Dict)&lt;/P&gt;&lt;P data-unlink="true"&gt;For those of you that are newbies to Python, like I am, this part was a little difficult because I wasn't understanding where some of the variables were coming from, such as "mapOptions" and "scale". Turns out, these are in the json, and this section is looking for the "scale" section in the "mapOptions" section of the json that's being taken from the web map and applying the new scale value from the Python script.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2020 15:42:47 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-12-18T15:42:47Z</dc:date>
    <item>
      <title>Error: Error in setting scale value; Using ConvertWebMaptoMapDocument/arcpy.mapping</title>
      <link>https://community.esri.com/t5/python-questions/error-error-in-setting-scale-value-using/m-p/1006935#M59215</link>
      <description>&lt;P&gt;Hi! I have created a widget that creates a PDF from a web map. It's working beautifully, and now I need to set the scale of the map on the printed PDF to a specific scale. It should be pretty straightforward (df.scale = 6000), but no matter what I do, I get the following error:&amp;nbsp;&lt;SPAN&gt;RuntimeError: DataFrameObject: Error in setting scale value&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I've done a lot of searching and tried many different things, but I either get the same error, or it runs but doesn't set the scale.&lt;/P&gt;&lt;P&gt;Here's what I've done (or at least what I remember):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Run the script with the data frame scale set in the .mxd as automatic and fixed scale (same error)&lt;/LI&gt;&lt;LI&gt;Added arcpy.RefreshActiveView()&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Below is a piece of my script; the selected point gets centered on the map, and I want it to zoom to a scale of 1:6,000, rather than stay at the scale of the web map. Can anyone help identify what I'm doing wrong? In case you need to know, the map document is in 10.5.1 and Python is v2.&lt;/P&gt;&lt;P&gt;Your assistance is much appreciated! Thanks!&lt;/P&gt;&lt;P&gt;Annina&lt;/P&gt;&lt;P&gt;# analysis&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;lyr = arcpy.mapping.ListLayers(mxd, "Points")[0]&lt;BR /&gt;# Selects the user-created point, zooms the data frame to the selected point, and then unselects the point&lt;BR /&gt;# so it doesn't show as teal in the map&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION")&lt;BR /&gt;df.zoomToSelectedFeatures()&lt;BR /&gt;df.scale = 6000&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")&lt;BR /&gt;# Removes the user-created point layer from the legend but keeps it in the map&lt;BR /&gt;drawn = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0]&lt;BR /&gt;drawn.removeItem(lyr)&lt;BR /&gt;## arcpy.AddMessage("Layer Name: " + lyr.name)&lt;BR /&gt;dictResult = PerformAnalysis(lyr, ExcelFileName)&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 13:55:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-error-in-setting-scale-value-using/m-p/1006935#M59215</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-12-04T13:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error: Error in setting scale value; Using ConvertWebMaptoMapDocument/arcpy.mapping</title>
      <link>https://community.esri.com/t5/python-questions/error-error-in-setting-scale-value-using/m-p/1010932#M59321</link>
      <description>&lt;P data-unlink="true"&gt;I did more searching and tried to understand some of the posts better. I used &lt;A href="https://community.esri.com/t5/python-questions/dataframe-scale-problem-when-map-created-through/td-p/326699" target="_self"&gt;this&lt;/A&gt;&amp;nbsp;post and Dev Tools. I was having trouble with reading it because of the one-line python script, but I finally got through it.&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I added my piece before the&lt;/P&gt;&lt;P data-unlink="true"&gt;result = arcpy.mapping.ConvertWebMapToMapDocument(Web_Map_as_JSON, templateMxd,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r'C:\temp\notes.gdb')&lt;/P&gt;&lt;P data-unlink="true"&gt;section, which is where the web map is converted to the document.&lt;/P&gt;&lt;P data-unlink="true"&gt;Here's my addition:&lt;/P&gt;&lt;P data-unlink="true"&gt;#Extra parameter - Scale&lt;BR /&gt;Scale = float(6000)&lt;BR /&gt;# modify Web_Map_as_JSON so that the web map scale matches the scale provided.&lt;BR /&gt;Web_Map_Dict = json.loads(Web_Map_as_JSON)&lt;BR /&gt;Web_Map_Dict["mapOptions"]["scale"] = Scale&lt;BR /&gt;Web_Map_as_JSON = json.dumps(Web_Map_Dict)&lt;/P&gt;&lt;P data-unlink="true"&gt;For those of you that are newbies to Python, like I am, this part was a little difficult because I wasn't understanding where some of the variables were coming from, such as "mapOptions" and "scale". Turns out, these are in the json, and this section is looking for the "scale" section in the "mapOptions" section of the json that's being taken from the web map and applying the new scale value from the Python script.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 15:42:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-error-in-setting-scale-value-using/m-p/1010932#M59321</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-12-18T15:42:47Z</dc:date>
    </item>
  </channel>
</rss>

