<?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 How to create offline_areas using extent in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-create-offline-areas-using-extent/m-p/445496#M34884</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;Hi,&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;I am trying to set layers in a webmap to be available for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;offline&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;use without success.&amp;nbsp; I want to create the offline areas using the layer extent, since I cannot create bookmarks from within python.&amp;nbsp; I would greatly appreciate any assistance.&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;I've written the following Python routine (using arcgis 1.7.0):&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;def enable_offline_use(gis, wm):&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&amp;nbsp; &amp;nbsp; #get each layer's extent and title&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for layer in wm.layers:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layer_obj = gis.content.get(layer['itemId'])&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; item_prop = {'title': layer_obj.title }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #make available&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;offline&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; wm.offline_areas.&lt;STRONG&gt;create&lt;/STRONG&gt;(layer_obj.extent, item_prop)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; wm.offline_areas.update()&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;This fails at the create call with:&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;EM&gt;... line 116, in enable_offline_use &amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;EM&gt;&amp;nbsp; wm.offline_areas.create(layer_obj.extent, item_prop)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\_types.py", line 1296, in create&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif isinstance(area, Envelope) or \&lt;BR /&gt;NameError: name 'Envelope' is not defined&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;_types.py does not import Envelope.&amp;nbsp; I can update the file as follows:&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;from arcgis.geometry import SpatialReference, Polygon,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Envelope&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;Now it goes past this point, but when turning on verbose I get the following error:&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;EM&gt;INFO:arcgis.geoprocessing._tool:Running script CreateMapArea...&lt;BR /&gt;&lt;STRONG&gt;object of type 'NoneType' has no len()&lt;/STRONG&gt;&lt;BR /&gt;ERROR:arcgis.geoprocessing._tool:object of type 'NoneType' has no len()&lt;BR /&gt;Completed script CreateMapArea...&lt;BR /&gt;INFO:arcgis.geoprocessing._tool:Completed script CreateMapArea...&lt;BR /&gt;Failed to execute (CreateMapArea).&lt;BR /&gt;ERROR:arcgis.geoprocessing._tool:Failed to execute (CreateMapArea).&lt;/EM&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;So to summarize:&lt;/DIV&gt;&lt;DIV&gt;&lt;OL&gt;&lt;LI style="margin-left: 15px;"&gt;Should I be adding "Envelope" to the _types.py file, or is my configuration missing something?&lt;/LI&gt;&lt;LI style="margin-left: 15px;"&gt;Am I doing something obviously wrong in my script?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Apr 2020 09:27:21 GMT</pubDate>
    <dc:creator>AgrimotionTeam</dc:creator>
    <dc:date>2020-04-03T09:27:21Z</dc:date>
    <item>
      <title>How to create offline_areas using extent</title>
      <link>https://community.esri.com/t5/python-questions/how-to-create-offline-areas-using-extent/m-p/445496#M34884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;Hi,&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;I am trying to set layers in a webmap to be available for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;offline&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;use without success.&amp;nbsp; I want to create the offline areas using the layer extent, since I cannot create bookmarks from within python.&amp;nbsp; I would greatly appreciate any assistance.&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;I've written the following Python routine (using arcgis 1.7.0):&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;def enable_offline_use(gis, wm):&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&amp;nbsp; &amp;nbsp; #get each layer's extent and title&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for layer in wm.layers:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layer_obj = gis.content.get(layer['itemId'])&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; item_prop = {'title': layer_obj.title }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #make available&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;offline&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; wm.offline_areas.&lt;STRONG&gt;create&lt;/STRONG&gt;(layer_obj.extent, item_prop)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; wm.offline_areas.update()&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;This fails at the create call with:&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;EM&gt;... line 116, in enable_offline_use &amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;EM&gt;&amp;nbsp; wm.offline_areas.create(layer_obj.extent, item_prop)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\_types.py", line 1296, in create&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif isinstance(area, Envelope) or \&lt;BR /&gt;NameError: name 'Envelope' is not defined&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;_types.py does not import Envelope.&amp;nbsp; I can update the file as follows:&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;from arcgis.geometry import SpatialReference, Polygon,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Envelope&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;Now it goes past this point, but when turning on verbose I get the following error:&lt;/DIV&gt;&lt;DIV style="color: #222222; background-color: #ffffff; font-size: small;"&gt;&lt;EM&gt;INFO:arcgis.geoprocessing._tool:Running script CreateMapArea...&lt;BR /&gt;&lt;STRONG&gt;object of type 'NoneType' has no len()&lt;/STRONG&gt;&lt;BR /&gt;ERROR:arcgis.geoprocessing._tool:object of type 'NoneType' has no len()&lt;BR /&gt;Completed script CreateMapArea...&lt;BR /&gt;INFO:arcgis.geoprocessing._tool:Completed script CreateMapArea...&lt;BR /&gt;Failed to execute (CreateMapArea).&lt;BR /&gt;ERROR:arcgis.geoprocessing._tool:Failed to execute (CreateMapArea).&lt;/EM&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;So to summarize:&lt;/DIV&gt;&lt;DIV&gt;&lt;OL&gt;&lt;LI style="margin-left: 15px;"&gt;Should I be adding "Envelope" to the _types.py file, or is my configuration missing something?&lt;/LI&gt;&lt;LI style="margin-left: 15px;"&gt;Am I doing something obviously wrong in my script?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2020 09:27:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-create-offline-areas-using-extent/m-p/445496#M34884</guid>
      <dc:creator>AgrimotionTeam</dc:creator>
      <dc:date>2020-04-03T09:27:21Z</dc:date>
    </item>
  </channel>
</rss>

