I'm creating a tool to change some 'Map Document Properties' (for example Title, Description, Author), with arcpy (it can also be model builder, or both), to execute from a personal toolbox.

But I want to know if is it possible to show the actual information of the property I want to change at the tool window, before I run it. Just like the 'Project' tool does. It reads the input coordinate system, and show it:

Project tool

I think it could be something like 'print', but to work before run the tool, and display it... But I do not know how to do it.

This way, I could run it in a batch mode, and easily see the mxd's that I really need to update, and the ones already updated.

It would be something like this:

Input mxd

MXD 'Map Title' (given)

MXD 'Map Title' Change (optional)


You would need to script this using python and arcpy to access the map document properties. If you read the help file on MapDocument (arcpy.mapping) and look at the Syntax section you will see that you can indeed read/write to these properties.

You would read the properties from an existing MXD in the validation event on your first parameter (the selecting of the MXD) and update the other parameters. Read the help page Understanding validation in script tools

By wiring up the script to a tool interface you can expose it as a geo-processing tool in a tool box which it self could then be dragged onto a model.

|improve this answer|||||
  • I alreay know how to access that information. I just do not know how to show it, in the tool window before run the tool. Just like the "Project" tool does. – raphael Jun 27 '17 at 14:07
  • 1
    Please do not overlook the main suggestion, Read the help page Understanding validation in script tools ! – fatih_dur Jun 27 '17 at 14:34
  • I'm not... I already read both suggested articles, but I'm not very familiar with that, so i'm here to get some help. I do not know how to execute a script in the validarion process. I already wrote the script that outputs the information I want. I just do not know how or where to use it. – raphael Jun 27 '17 at 14:44
  • 1
    Sounds like your next step is to have a play with a simple script and understand how to update a parameter during the validation step. Have a look at the system tool "Add Geometry Attributes", go to it's properties and then click on the validation tab at the top, this will give you the understanding of how to call validation code. – Hornbydd Jun 27 '17 at 16:01

This is what i did, as validation:

  def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed.  This method is called whenever a parmater
has been changed."""
if self.params[0].altered:
  import arcpy, os, glob, arcgisscripting
  gp = arcgisscripting.create()      
  filename = gp.GetParameterAsText(0)
  mxd = arcpy.mapping.MapDocument(filename)      
  self.params[1].value = mxd.title
|improve this answer|||||

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.