Taking hold of the Python – Part 3


When to create a Python Add-in

Before you decide to make an add-in, be sure it is the right development path for your project requirements.

If you want to add a collection of existing tools on a toolbar, or change the layout of menus or toolbars in an ArcGIS for Desktop application, you can configure the user interface (UI) to match your preferences. This does not require any programming or scripting..

If you need to run a set of geoprocessing tools to perform data analysis or data management, or produce a series of maps, consider creating a model with ModelBuilder or writing a Python script

If it is required to make a customization that performs an action in response to an event, or requires the use of the mouse to interact with the display, you should consider making an Add-in. An example is a tool that requires the user to click and drag a rectangle over a map to define an area of interest. Another example is an application extension that saves the map document automatically anytime a layer is added or removed from the table of contents.

Limitations

Python interaction with ArcGIS is mainly limited to reading and writing data, editing the properties of map documents, and running the tools that are included with ArcGIS. Although the ArcGIS tools are useful, they are somewhat black box, meaning you put things in and get things out without knowing or being concerned about what is happening inside. If you want a greater degree of control over how ArcGIS is manipulating your data, you need to work with ArcObjects.

A workaround for this has been to invoke 9.3 functionality within the arcpy module by importing arcgisscripting from within arcpy. This could bring up some backward compatibility issues, so it is necessary to compare each geoprocessing tool to determine what, if any, changes have been made.

Because of the sheer amount of functionality and objects available to you, ArcObjects is more challenging to learn than simple Python scripting. Usually, an equivalent task takes many more lines of code to write in ArcObjects than in a Python script. However, when you use ArcObjects you have much greater control over what happens in your program. You can take a small piece of functionality and use it without the overhead of a tool or all the other parameters that come with a tool.

To look at the pydoc in Python. You can open that from Python with these 2 lines:

import pydoc

pydoc.gui()

… or just access it through the Desktop > Start > All Programs > ArcGIS > Python 2.x > Module Docs.

For an updated OMD for Geoprocessing Object Model v10:

forums.arcgis.com/attachment.php?attachmentid=4646&d=1297133686

Note that there are many new modules, classes and functions in arcpy that have no equivalent in arcgisscripting so while this is a great start, it will take quite a bit more effort to make it a complete document.

Good luck taking hold of the Python!

Ricardo A

Got something to say?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s