Tag Archives: VBA

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. Continue reading

Taking hold of the Python – Part 2

Getting started

You don’t have to be a programmer to write Python scripts. You can start by learning the basic Python syntax and its built-in types. Once you know the basics, you can write Python scripts to automate geoprocessing, map production, and data management tasks in ArcGIS.

I think ModelBuilder actually provides the easiest start. Note that once you’ve constructed your Graphic UI model in ModelBuilder, when you save it, it gets compiled into Python script which allows you to go through and get more familiar with the syntax and logic construction.

Something similar can be done from the Results window, where you have the option to copy geoprocessing tool results as Python snippet code. Being able to access a detailed record of your geoprocessing operations, with tool inputs pre-populated, is a powerful timesaver when you need to repeat the same workflows. Continue reading

Taking hold of the Python – Part 1

Esri have been phasing out VBA in favour of Python since ArcGIS 10.0.

Reason for transition – Microsoft has stopped supporting VBA. Since the release of ArcGIS 10, VBA was no longer recommended for use as it was not going to be included in subsequent versions, including 10.1. However it was still available in order to support legacy code and applications. A migration to Python, an open source programming language, was thus necessary.

Python is free, cross platform, open source, stable, mature, simple, and powerful. Benchmarking has shown that Python processes scripts in about a third of the time that VBA does.

Continue reading