10

I have been tasked with creating a model using ArcGIS ModelBuilder, that initially runs a couple of geoprocessing tasks, before then joining an Excel table to the result of those geoprocesses. However, the model needs to actually open the Excel file first, for the user to manually edit it, before the user then saves their edits and closes the file. It is then expected that the model will join this Excel file to the attribute table of a dataset (still part of the model) before the model continues on with a number of other geoprocessing tasks.

I include a high-level schematic outline below to help illustrate the point (I understand this might not make a lot of sense to start with).

The model would pause whilst the Excel file is edited, then resume once saved and closed

So the model would run, complete a couple of geoprocessing tasks, pause to open an Excel file, wait for the user to edit it, save it and close it, before resuming to join that Excel file to an attribute table and then running a number of other geoprocessing tasks.

I should imagine this would require incorporating a Python script or two into the model. Currently though I am just interested to know whether the concept is actually possible or not.

  • 1
    I'm pretty sure with standard model builder tools you will not be able to do this as there is no way of pausing the model, you would also need some sort of trigger to fire to say the user has closed Excel to restart the model. You may be able to achieve this with some sort of script sent into an infinite loop looking at a flag in a text file after it has spawned a separate process (Excel)? I've never done that and don't know what the pitfalls are. If you want to keep it in modelbuilder I would do the excel edits first then run the model. – Hornbydd Dec 5 '13 at 12:59
  • Thanks @Hornbydd - I have had the same thoughts. Editing the file first and then running the model is what I have suggested, but I have been told that is needs to be one, integrated model... – the_bonze Dec 5 '13 at 13:01
  • 1
    I figure a script could look at the date and time stamp of a file to know if it has been edited, then resume the model from there? Pausing it is the problem, I think. – the_bonze Dec 5 '13 at 13:02
  • Yeah, model builder is designed to automate a workflow to speed up processing not have some indeterminate pause in the middle, what happens if that user goes off for lunch for example? :) Just like me now! – Hornbydd Dec 5 '13 at 13:12
1

This sounds like you need to develop more of a custom Python tool than a model in ModelBuilder. xlwt or xlutils at http://www.python-excel.org/ will let you write to your Excel file (XlsxWriter will handle xlsx files). If the edits are minor, you could probably incorporate this in a standard ArcToolbox tool (with some creativity). If you are using 10.1+, then you could create a Python Add-In or Python Toolbox to do the GUI work in as well.

  • Do Python AddIns already provide sophisticated GUI options in 10.1+? I thought only .NET and Java AddIns provide these...Python only offers AddIns without any GUI (commands, tools). – Jürgen Zornig Dec 5 '13 at 14:50
  • 1
    @JürgenZornig It's not thaaaat easy: anothergisblog.blogspot.com/2013/07/… – Chad Cooper Dec 5 '13 at 15:26
  • Thanks @ChadCooper. I need to keep the model in model builder, so Python add-ins are fine, but the model as an entity needs to be in model builder rather than a full-blown Python tool. – the_bonze Dec 5 '13 at 16:14
  • @Chad Thanks anyway for this nice ArcPy/Tkinter Quickstart Tutorial...have to try this! – Jürgen Zornig Dec 5 '13 at 18:47
1

I've been thinking about it and it's possible I've found a novel solution. You set up a python script in a toolbox with two user parameters, firstly the location of the Excel EXE. This could even be smartly coded to check a list of hardcode likely filepath locations (Office12, Office13 etc).

Next use the subprocess.call function. There some really neat things about using this method:

  1. It doesn't require any external libraries
  2. the call function doesn't allow continuation of the script until excel it is closed
  3. You can specify the excel document as the second argument
  4. It's one line of code!

    import subprocess subprocess.call(["C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE", "Test.xlsx"]) #Replace args with user inputs (sys.argv[1], sys.argv[2] respectively)

The only thing is I'm not 100% sure if this will work in the model builder, this will need to be tested, however I don't see why it wouldn't but as I'm sure you're aware Arc is a temperamental beast.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.