Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Since the ability to store mxds inside a file gdb is still just an idea, I've been mulling over my options for using a "template" mxd within a model. My model uses 4 different mxds, but currently it accepts one at a time (i.e. I run the model 4 times for each feature class, using the different mxds). The model does various things such as saving a copy of the "template" as a new mxd, replacing data sources etc.

Up to now I have "Input Template mxd" as a model parameter. This is fine, if I'm the one running the model, so I know which mxd is the correct one. However, if someone else were to run the model, they could input any mxd they wished, which would inevitably lead to the model failing. The options I thought of were:

1. Trust that the user will enter the correct template mxd containing 
   the correct layers: if only.
2. Force the user to enter a template mxd which has the correct name: 
   won't work in this multiple template mxds scenario, as I would then have to 
   duplicate the model 4 times to check for the 4 different names. Alternatively,
   if I wrote an if statement inside the model to check which template I'm receiving,
   it still would not potentially stop the user from renaming Template1.mxd to 
   Template2.mxd, causing the wrong processes to run.
3. Store the templates inside the same file gdb with the model: as stated, 
   cannot be done.

My current scenario has my model and template feature classes inside a gdb, inside a folder along with the four template mxds. The model automatically accesses each template mxd as needed, so the branch for each template runs consecutively everytime the model is executed. However, the user could still rename the mxds, or simply remove them from the folder...

My question is, is there a way to somehow store the template mxds within the model itself or in some other way so that the user cannot change it?

share|improve this question

3 Answers 3

up vote 3 down vote accepted
+50

Since you are concerned about the user running the wrong mxd, I would suggest removing that mxd model parameter, and use Iterate Files option to run your model against each template mxd.

share|improve this answer
    
I tested this briefly, and this is the solution (mostly) that I have been looking for. While the user would still be able to change the templates within the folder, I realised that the templates are not cast in stone (I have had to change them several times after they were supposed to be "final"), so the user might very well have to edit the templates themselves before running the model. I guess for now I have to trust that the user knows what they are doing - or at least be available for (inevitable?) technical support. –  Cindy Williams Sep 3 '12 at 5:21

You can provide all necessary additional files (mxds) in a zip archive. To further protect them you can set password for such archive or compare checksums.

In order to do it you need to create and use python script in your module. Just write script which will unzip your mxds to some temporary folder (you can pass this folder and zip file as an input parameter for your script). Then add this script to your Toolbox and use it in you model in Model Builder.

Another way is to export your whole model to python and perform further development there. I am usually prefer this way in cases when I am facing additional more complex processing tasks and have needs in other libs.

There is even one more way: you can create python script for ArcToolbox which will accept all needed input parameters then unzip your mxds and execute your custom model (the one you have now), then perform all cleaning (of unziped files). In such way you just changing entry point for your processing task.

Here is some points to start from:

  1. How do I zip the contents of a folder using python?.
  2. Unziping files in python
  3. Considerations when exporting a model to a Python script
share|improve this answer
1  
I wonder if you could use Python Add-ins in ArcGIS 10.1 to package the MXDs and data with your add-in. The add-in framework would handle the unzipping of files automatically, and so long as you were just using them as templates and not rewriting the template MXDs you shouldn't need to worry about them being overwritten by the add-in framework (which IIRC it does at every app startup). If you are stuck on 10.0 you could of course also do this with .NET/Java add-ins. –  blah238 Aug 29 '12 at 8:34
    
Yep, this is also a good solution for 10.1 ! –  Alex Markov Aug 29 '12 at 8:42
    
This looks fantastic! Though a model/script will suffice for now, this (ever expanding) model will be reused across multiple (similar) projects, so the idea of creating an add-in is exciting. Still on 10.0, but will be moving to 10.1 soon. I'll try out these ideas later this week. –  Cindy Williams Aug 29 '12 at 9:34

If I am understanding it right: You can use a variable (or meaningful pick list) and then insert a If ..else conditional loop for all these mxds.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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