How to set "map description" parameter in arcpy.PackageMap_management ?

1779
6
02-02-2017 07:07 PM
KaustavChaudhury1
New Contributor

I recently started using arcpy to handle batch tasks for arcgis. I am trying to run the arcpy packagemap_management tool to batch export a bunch of mxds inside a folder.

 

This is what I am running now:

-----------------------------------

>>> import os
import arcpy

arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\ABC\DirectoryToMxd"

for mxd in arcpy.ListFiles("*.mxd"):
print ("Packaging: {0}".format(mxd))
arcpy.PackageMap_management(mxd, os.path.splitext(mxd)[0] + '.mpk', "PRESERVE", "CONVERT_ARCSDE", "#", "ALL")


Packaging: Test.mxd
Runtime error Traceback (most recent call last): File "<string>", line 9, in <module> File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 8197, in PackageMap raise e ExecuteError: #ERROR 001117: Map description property must be set Failed to execute (PackageMap).

-------------------------------

From the error , it seems the code is working but due to the mandatory requirement for map description during mpk export ,it is throwing an error. I checked geonet doc and did not find any parameter to set "description". It only supports summary and tags through command line. 

 

 

Can someone please help me fix this? Is there a hidden parameter I can use to set the map description for all the exports?

0 Kudos
6 Replies
DanPatterson_Retired
MVP Esteemed Contributor

The input layer must have a description in order for the tool to execute. To add a description, right-click the layer, click Properties, and enter a description

from the help topic which means you need to set it.  Perhaps you can set it via code from within the Layer section, there is the property there you are looking for

KaustavChaudhury1
New Contributor

Hello Dan,

Good to hear from you!

Can you please elaborate your suggestion? If you meant to check the map_management help topic, I already did that. And I didnt find any option/parameter for defining the map description via python code.

Basically I am trying to set the below fields via command line during mpk creation:

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

in the link on layers, under properties

description
(Read and Write)
Provides the ability to either get or set the layer's description information. Not all layers support the description property (for example, topology layers), so it is good practice to test for this ahead of time using the supports method.
String

Which means you can get and/or set it with arcpy

To clarify.... the layers need to have their description set in order for them to be packaged... at least that is my reading of the packagemap help and the layer help

0 Kudos
KaustavChaudhury1
New Contributor

This description seems to be for individual layers. I am looking for "Map Package" property: Description field. 

Please have a look at the screenshot I shared in my earlier comment.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

MapDocument—Help | ArcGIS Desktop  I guess I am reading the error wrong then, since the error noted in step 6

Creating a map package—Help | ArcGIS Desktop had to do with the unresolved mapdocument not having the correct requirements, which can be set at the mapdocument level.

 

The package map code script which you posted doesn't even show the need to provide a map package description.

I am also assuming that you code example just lacks proper indentation because of not using the syntax highlighter.  You might want to check that the arcpy.env.workspace path should be set to a raw format string ( ie r"c:\somefolder") but I doubt that these would have thrown that error.

I you get this issue straightened out, please post back

0 Kudos
KaustavChaudhury1
New Contributor

I am able to perform a simple "print" statement for all the mxd inside that folder and getting desired results. So I am sure it is not an python indentation problem. the piece of code is able to read through the contents inside the folder and not throwing any error. 

The issue is tied to the mandatory requirement for "package map" description field. But there is no parameter associated with arcpy packagemap_management which I can fill through command line.

The error clearly shows that the description is necessary ,but it does not support pushing that value through the above code.

Runtime error Traceback (most recent call last): File "<string>", line 9, in <module> File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 8197, in PackageMap raise e ExecuteError: #ERROR 001117: Map description property must be set Failed to execute (PackageMap).

Now since I want to iterate the job for all the mxds inside the folder, how do I bypass that requirement. Or rather set it via arcpy using the above code for all the mxds. 

0 Kudos