Automatization of ArcMap

907
2
08-23-2014 04:05 AM
NickPopow
New Contributor II

Deal All.

I need to get an idea how to write a scenario for ArcMAP. There is a external code which provides a numerical result for ArcMAP calculations. After finishing of this code ArcMAP need to be started to join this data to my shape file and convert and export it to KML. I tried to use ModelBuilder but it can be started only under ArcMap. The other way is to write Python script for starting Arcmap and doing my Model. Am I right or it is possible to start Model under Windows or Command line?

0 Kudos
2 Replies
RiyasDeen
Occasional Contributor III

Hi Nick,

Yes you can call your model from command line.

  1. Export your model as Script file.
  2. Include below lines at the start of your script

# Import system modules

import sys, string, os, logging

WORK_FOLDER = "E:\\Workfolder"

# initiate logging

logging.basicConfig(filename=WORK_FOLDER+'Script.log',format='%(asctime)s %(message)s',level=logging.DEBUG)

# Set the License...

arcpy.SetProduct("ArcEditor")

logging.debug('product initialised')

# Load required toolboxes...

arcpy.AddToolbox("c:\program files\arcgis\desktop10.2\ArcToolbox\Toolboxes\Data Management Tools.tbx")

arcpy.AddToolbox("c:\program files\arcgis\desktop10.2\ArcToolbox\Toolboxes\Conversion Tools.tbx")

logging.debug('Loaded toolbox')

Now you can execute this script from command line or scheduled task by calling python.exe like below.

c:\python27\python.exe c:\gisWork\myscript.py

NickPopow
New Contributor II

Hi Riyas!

Thank you for your help! I've got an idea!

0 Kudos