Script Mobile Map Package Update

1348
5
01-15-2020 06:36 AM
CiaranHiggins1
New Contributor II

I have a mobile map package which i created in pro, however i will want to refresh the data.

What is the syntax for setting the input map conatined within the project to create a mobile map package?

 

For example using the python console in pro mine would be as follows:

 

arcpy.management.CreateMobileMapPackage("Map Title", r"J:\path\PackageName.mmpk", None, None, "DEFAULT", "SELECT", "Title", "Summary", '<DIV STYLE="text-align:Left;font-size:12pt"><P><SPAN>Sewer Network</SPAN></P></DIV>', "Sewers", None, None, "STANDARD")

This works perfectly, however i want to run a script where i don't have to be in the Python console in Pro.

 

The code sample in this help article

https://pro.arcgis.com/en/pro-app/tool-reference/data-management/create-mobile-map-package.htm

for a stand alone script is as follows:

 

arcpy.management.CreateMobileMapPackage( [r"C:\data\Basemap1.mapx", r"C:\data\Map1.mapx"], outputfile, None, r"\\share\layers\AreaOfInterest.lyrx", "DEFAULT", "CLIP", "Title", "Summary", "description", "Tag", "Credits", "Use", "STANDARD", "ENABLE_MAP_EXPIRATION", "DONOT_ALLOW_TO_OPEN", expiration_date, "This map is expired. Contact the map publisher for an updated map.")

 

but the input is a map file, how do i set the input to be a map within a project?

 

Any help would be much appreciated.

5 Replies
DanPatterson_Retired
MVP Emeritus

If arcpy is open, then you will be using the "CURRENT" project

ArcGISProject—ArcPy | ArcGIS Desktop 

CiaranHiggins1
New Contributor II

Thanks for the quick response Dan.

I could be doing soemthinre really silly. I am trying to do this as a standalone script so ArcGIS Pro would not be open. What i tried was as follows:

import arcpy

arcpy.management.CreateMobileMapPackage(r"J:\PathtoProject\Project.aprx"), r"J:\PathtoMapPackage\SewerNetwork.mmpk", None, None, "DEFAULT", "SELECT", "Sewer Network", "Sewer Network", '<DIV STYLE="text-align:Left;font-size:12pt"><P><SPAN>Sewer Network</SPAN></P></DIV>', "Sewers", None, None, "STANDARD")

However this does not work. I also tried the following:

import arcpy
aprx = arcpy.mp.ArcGISProject(r"J:\PathtoProject\Project.aprx")
arcpy.management.CreateMobileMapPackage("Sewer Network", r"J:\PathtoMapPackage\SewerNetwork.mmpk", None, None, "DEFAULT", "SELECT", "Sewer Network", "Sewer Network", '<DIV STYLE="text-align:Left;font-size:12pt"><P><SPAN>Sewer Network</SPAN></P></DIV>', "Sewers", None, None, "STANDARD")

This also does not work

ericmeyers_cob
New Contributor II

Did you ever get a resolution to this? I am trying to do the same thing and am currently working with ESRI technical services to find a solution. I'm even trying after grabing the ArcGIS Pro Project, I'm diving in deeper with the map object. You can get this through the .listmaps() method. When plugging this in it still seems to fail. I see the opportunity to export a map to .mapx. Is that really the solution here though? To export to .mapx first in order to do a .mmpk export? There has got to be a smoother way.

0 Kudos
by Anonymous User
Not applicable

Any updates on getting this to work?  Also trying to have a standalone python script - package and upload mmpk to ArcGIS online. 

0 Kudos
tiztrain
Occasional Contributor

I am also running into this situation. I believe the correct workflow would be:

  1. Use "Create mobile map package" geoprocessing tool
  2. Use "Share package" and input the mmpk created from step 1

Share package will overwrite the existing package if it has the same name.

0 Kudos