Create Mobile Map from ArcObjects or Python

3610
21
10-06-2010 11:50 PM
AndersWallberg
New Contributor II
I would like to automate the Mobile map creation in ArcGIS 10 from ArcObjects or Python, but can not get any of them to work. As far as I can see there is't a GPTool available for Mobile Tools in ArcObjects or am I wrong?

When I did not find it possible to use ArcObjects for this I started to look at Python. I am new to Python so maybe I am doing some misstakes here. From the Python window in ArcMap I got this simple script to work after I disabled the Background Processing option i Geoprocessing options:
##################
import arcpy
arcpy.CreateMobileMap_mobile("c:/Temp/MyMxd.mxd", "c:/Temp", "","","","")
##################

But I cant get a similar code to work in a stand alone Python script:
##################
import arceditor
import arcpy
from arcpy import env

arcpy.SetProduct("ArcEditor")

arcpy.env.scratchWorkspace = r"C:\Documents and Settings\WMUser\My Documents\ArcGIS\Default.gdb"
arcpy.env.workspace = r"C:\Documents and Settings\WMUser\My Documents\ArcGIS\Default.gdb"

map_document = r"c:\Temp\MyMxd.mxd"
output_folder = r"c:\Temp"

arcpy.CreateMobileMap_mobile(map_document, output_folder,"#", "#", "#", "#")
##################

The script does not generate any errors and I can not se any errors in the C:\Documents and Settings\WMUser\Application Data\ESRI\Desktop10.0\ArcToolbox\History log either.

Any help would be appreciated.

Anders
21 Replies
AkhilParujanwala
New Contributor III
Hi, I do beleive you can do both Python or ArcObjects, I have yet to start that part of the project where we would need to create mobile maps quickly ( I have been working on the application itself).

But the quickest way to do this is to using Model Builder, then convert it to a Python script.

This way you can create a your own toolbox and a tool in which you can easily click on one button and it will run what you want. Plus since you can convert it to a python script anyways, you can just run the script instead of the tool itself.
0 Kudos
AndersWallberg
New Contributor II
Thanks for your quick reply Akhil.

I have already tried to to what you are suggesting, I created a tool that uses the Create Mobile Map Tool using the Model Builder. This tool works fine within ArcMap, but when i export the script to a Python script I get this error when I run it:
--------------
Traceback (most recent call last):
  File "MyMobileMapCreatorExport.py", line 24, in <module>
    arcpy.CreateMobileMap_mobile(mapdocument, output, "", "-4684579,73390153 -11
000940,2408731 7684579,73390153 11000940,2408731", "", "")
  File "C:\Program Files\ArcGIS\Mobile10.0\ArcToolbox\Toolboxes\Mobile Tools.tbx
", line 47, in CreateMobileMap

AttributeError: 'NoneType' object has no attribute 'CreateMobileMap_mobile'
--------------

MyMobileMapCreatorExport.py is my exported script. But the message points to an error at line 47 in Mobile Tools.tbx.

Please send a note if you have any success in your project with an export using ArcObjects or Python.

Anders
0 Kudos
AkhilParujanwala
New Contributor III
Ok great you've done all the ground work, from my experience with Python  you may want to change this line slightly:

File "C:\Program Files\ArcGIS\Mobile10.0\ArcToolbox\Toolboxes\Mobil e Tools.tbx

to

File "C:\\Program Files\\ArcGIS\\Mobile10.0\\ArcToolbox\\Toolboxes\\Mobil e Tools.tbx

Yes double backslash.
Or even a Single forward slash /   or even a double forward slash //

Its been a while since I have touched python but that is one thing I do remember modifying when I was creating python scripts from scratch.

I hope this helps, otherwise you may want to look at another forum section to help out.


Thanks,

Akhil P.
0 Kudos
BillRose
New Contributor III
Does anyone have an update on this issue? It looks like another bug to me.

CreateMobileMap() works reliably from within ArcGIS Desktop but fails when executed from a standalone script. The code below even reports success after failing to generate any output.



import arceditor, arcpy

# Both local and non-UNC paths were also tested. This convention works in other contexts.
mapSource = r"\\myserver\myFolder\myMap.mxd"
mapOutput = r"\\myserver\myFolder\myOutput"

try:
    arcpy.CreateMobileMap_mobile(mapSource, mapOutput, "", "11728606.6500131 3679369.25521957 11823287.5018783 3755318.48711422", "", "")

except:
    print "ERROR"

print arcpy.GetMessages()
0 Kudos
AndersWallberg
New Contributor II
Well it seems like a bug to me too. I contacted their support and the support team admitted that this is not working. The support team has reported this bug to the developers at ERSI Inc. so hopefully they will provide a hotfix to this issue soon.

Anders
0 Kudos
JosephThirolf
New Contributor
Any update from ESRI on this? We need to be able to create mobile map cache files using ArcObjects in our .NET code.

Regards,
Joe
0 Kudos
BillRose
New Contributor III
Any update from ESRI on this? We need to be able to create mobile map cache files using ArcObjects in our .NET code.

Regards,
Joe


It appears that Python standalone execution of this tool still fails in service pack one which was just released this week (2010.11.15).
0 Kudos
AndersWallberg
New Contributor II
The latest information I got on this from ESRI is that SP1 and a Hotfix is required to get this to work. The bug ID is NIM062051. We were told that this Hotfix should have come last week but we are still waiting for it.

Regards Anders
0 Kudos
FrédéricHUMBERT-DROZ
New Contributor
Dear All,

Have you had any news about this issue ?

Even after the SP1, when I run the "CreateMobileMap_mobile" geoprocessing from dotnet code, it returns successful and 3 temporary folders are created in C:\Windows\Temp. Each of them contains the same 3 files: "MapSchema.bin", "MobileCache.db" and "MobileCache.db-journal".

It seems it ignores the output folder parametter I set, and then generate an empty mapcache...

Is there any workarround or fix ?

Best regards,
0 Kudos