1

I am trying to teach myself Python scripting for ArcMap, however I'm stuck with possibly a very simple issue.

All the tutorials in my books start with "Open the file with ArcMap" without mentioning how to do this through the console.

But what I want is to build my scripts by having an implicit presence of file within the Python environment.

However, the best I found so far is:

os.startfile(PATH-TO-THE-FILE)

which opens the ArcMap window and loads the file.

This is not bad, however:

  1. I'm getting A WINDOW when scripting outside ArcMAP
  2. I'm getting ANOTHER WINDOW when scripting inside ArcMAP

So to sum up - I am particularly interested in answering two questions:

  1. Can I do the whole processing just from Python IDLE? Open the file, merge it with another files, do the geoprocessing, save/print results...?

  2. If the answer to previous is TRUE, then how can one easily switch between loading the files to ArcMAP (when running the script in its console) and doing the whole job externally? I'd prefer to see what the script does at first (work inside ArcMAP's Py console) and when the script is done then move it out and run it on periodical basis within Python IDLE.

closed as off-topic by PolyGeo Nov 8 '16 at 23:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    3. Yes totally possible and it is how most people run their scripts. 4. I am not quite sure what you mean, can you clarify a little bit. – ed.hank Nov 7 '16 at 17:17
  • are you starting the .mxd or the python .exe with path-to-the-file – Geoffrey West Nov 7 '16 at 18:52
  • Do you like to develop a user interface/GUI for python to allow user work independently outside ArcGIS custom toolbox? – Shiuli Pervin Nov 8 '16 at 9:08
  • Hi, thanks for your comments. @ed.hank: The idea is, that I write a script, such as this one (comes from a book): 'import arcpy, os os.startfile(r"C:/Users/K1_Adm/Desktop/Programming ArcGIS/Ch2/Crime_Ch2.mxd") try: arcpy.env.workspace = "c:/ArcpyBook/data/" fields = arcpy.ListFields("Building_Permits.shp") for fld in fields: print fld.name except: print arcpy.GetMessages()' – Jakub Weiner Nov 8 '16 at 9:56
  • 1
    can you edit your question and attach the code you have written so far. It will help a lot. – ed.hank Nov 8 '16 at 15:17

Browse other questions tagged or ask your own question.