AnsweredAssumed Answered

Create Map Tile Package - Cannot run python script

Question asked by vfranca on Mar 9, 2016
Latest reply on Mar 9, 2016 by Dan_Patterson

Hi folks,

 

Using ArcGIS version is 10.2.2, I am trying to use arcpy.CreateMapTilePackage_management() GP tool in the script bellow to automate production of a large quantity of map packages to be used in handheld devices. I can create packages using the menu - File > Share As > Tile Package, but can not put the script to work, neither using ArcMap Python window or IDLE. I get the same error message:

 

Runtime error

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 7170, in CreateMapTilePackage

    raise e

RuntimeError: Object: Error in executing tool

 

Here is my script:

import arcpy, os

import arcpy.mapping

 

mxd = arcpy.mapping.MapDocument('CURRENT')

df = arcpy.mapping.ListDataFrames(mxd, "MSR") [0]

 

# Cursor

for row in arcpy.SearchCursor("T_LM_SETORES"):

  df.extent = row.SHAPE.extent # ajusta a extensao do dataframe a extensao do setor

  df.scale = df.scale * 1.1 # ajusta a escala para dar uma margem maior ao setor no mapa

  arcpy.RefreshActiveView()

  geocodigo =  row.getValue("cd_geocodigo")

  mxd.save()

  print("Saving map tile package for sector " + geocodigo)

  arcpy.CreateMapTilePackage_management( mxd, "ONLINE", r"G:\\BaseTerritorial\\Atendimentos\\2PP_CensoAgro\\MapTilePackages\\" + geocodigo + ".tpk", "JPEG", "19", "#", "Test map package generation", "tag1, tag2")

 

Outcomes