Introduction to Programming Arc Objects Using VBA

8
Introduction to Programming ArcObjects using VBA Three days Overview ArcObjects components are the building blocks of the ArcGIS family of products, and the ArcObjects libraries provide a rich set of functionality that developers can use to build powerful GIS applications. This course introduces the ArcObjects libraries to Visual Basic for Applications (VBA) programmers and teaches how to develop custom applications and solutions that extend core ArcGIS functionality. Students work with VBA development tools and the ArcGIS Customize dialog box and learn how to use the various help resources available. In course exercises, students work with the ArcObjects VBA developer resources to create applications and tools that perform specific GIS tasks including map navigation, feature selection and rendering, spatial operations, data projection, data management, editing, geoprocessing, and map creation. Audience This course is designed for experienced VBA developers and experienced ArcGIS users who are new to programming ArcObjects. Prerequisites and recommendations Students should have completed ArcGIS Desktop II: Tools and Functionality or Learning ArcGIS Desktop or have equivalent knowledge. Intermediate programming experience in Visual Basic or VBA is also required. Those with no Visual Basic or VBA programming experience should take Learning Visual Basic for Applications for New ArcGIS Developers or Introduction to Visual Basic 6 before taking this class. Goals Those completing this course will be able to: o Customize the ArcGIS graphical user interface. o Describe the architecture of the core ArcObjects libraries. o Illustrate the most effective ways to use the components of the software development kit (SDK) and developer tools to implement custom functionality. o Use ArcObjects to develop GIS functionality using VBA. o Write reusable code for automating tasks in ArcGIS.

Transcript of Introduction to Programming Arc Objects Using VBA

Page 1: Introduction to Programming Arc Objects Using VBA

Introduction to Programming ArcObjects using VBA

Three days

Overview

ArcObjects components are the building blocks of the ArcGIS family of products, and

the ArcObjects libraries provide a rich set of functionality that developers can use to

build powerful GIS applications. This course introduces the ArcObjects libraries to

Visual Basic for Applications (VBA) programmers and teaches how to develop custom

applications and solutions that extend core ArcGIS functionality. Students work with

VBA development tools and the ArcGIS Customize dialog box and learn how to use

the various help resources available. In course exercises, students work with the

ArcObjects VBA developer resources to create applications and tools that perform

specific GIS tasks including map navigation, feature selection and rendering, spatial

operations, data projection, data management, editing, geoprocessing, and map

creation.

Audience

This course is designed for experienced VBA developers and experienced ArcGIS users

who are new to programming ArcObjects.

Prerequisites and recommendations

Students should have completed ArcGIS Desktop II: Tools and Functionality or

Learning ArcGIS Desktop or have equivalent knowledge. Intermediate programming

experience in Visual Basic or VBA is also required. Those with no Visual Basic or VBA

programming experience should take Learning Visual Basic for Applications for New

ArcGIS Developers or Introduction to Visual Basic 6 before taking this class.

Goals

Those completing this course will be able to:

o Customize the ArcGIS graphical user interface.

o Describe the architecture of the core ArcObjects libraries.

o Illustrate the most effective ways to use the components of the software

development kit (SDK) and developer tools to implement custom functionality.

o Use ArcObjects to develop GIS functionality using VBA.

o Write reusable code for automating tasks in ArcGIS.

Page 2: Introduction to Programming Arc Objects Using VBA

Topics covered

Programming with COM: Cclasses, class libraries, COM, query interface, creating

objects.

Object model diagrams: Object model diagrams, types of classes, inheritance.

The ArcGIS application framework: Customize dialog box, Visual Basic Editor.

Working with maps and layers: Active data frame, layer properties.

Accessing data with ArcObjects: Accessing existing data using ArcObjects.

Displaying data: Feature and raster data rendering.

Working with queries and selections: Cursors and feature cursors, selection sets.

Geometry and spatial analysis: Spatial analysis, spatial reference, calculating area.

Data creation and editing: Creating new data, editing using cursors.

Geoprocessing: Running geoprocessing tools, setting environments.

Working with layouts: Making maps, adding elements, exporting and printing.

ArcObjects beyond VBA: Extending applications, ArcGIS Engine, ArcGIS Server.

Page 3: Introduction to Programming Arc Objects Using VBA

Course Outline:

The ArcGIS application framework

o The ArcGIS application framework

o VBA development environment

o ArcGIS commands

o Customize dialog box

o Customize dialog box: additional options

o Accessing your customizations

o Working with forms

o Creating macros

o Creating UIControls

o UIControl example: Tools

o Setting UIControl properties

o Writing code for UIControls

o ThisDocument code module

o MxDocument events

Programming with COM

o Classes and objects

o ArcObjects class libraries

o Commonly used libraries

o Important terms

o Visual Basic syntax

o Component Object Model (COM)

o COM classes have interfaces

o Working with ArcObjects COM classes

o Polymorphism

o ArcObjects polymorphism

o Using methods and properties

o Accessing other interfaces on same object

o Conceptual QI example

o ArcObjects QI example

o Getting started with ArcObjects

o Tying it all together

Page 4: Introduction to Programming Arc Objects Using VBA

Object model diagrams

o OMD relationship symbols

o Properties and methods

o Coclass

o Class

o Abstract class

o ArcMap objects

o Type Of inheritance

o Interface inheritance

o Working with properties

o Setting properties

o Working with IMxDocument

o Developer resources

Working with maps and layers

o Object model overview

o Accessing maps

o Looping through a collection of maps

o Locating a map by name

o Accessing layers

o Working with a map’s layers

o Accessing layers in an enumeration

o Locating a layer by name

o Working with layer properties

o FeatureLayer properties

o Enumerations

o RasterLayer properties

o Testing an object reference

o Setting a FeatureLayer’s data source

o Map events

o Accessing data with ArcObjects

o Data creation objects

o Accessing workspaces

o Open existing workspace

o Accessing feature classes

o Adding feature layers to ArcMap

o Accessing data using ArcSDE technology

o Connecting to an ArcSDE geodatabase

Page 5: Introduction to Programming Arc Objects Using VBA

o Adding a data layer: pseudocode

o Adding a data layer: solution

o Adding layers through a custom GxDialog

o GxDialog code example

Accessing data with ArcObjects

o Data creation objects

o Accessing workspaces

o Open existing workspace

o Accessing feature classes

o Adding feature layers to ArcMap

o Accessing data using ArcSDE technology

o Connecting to an ArcSDE geodatabase

o Adding a data layer: Pseudocode

o Adding a data layer: Solution

o Adding layers through a custom GxDialog

o GxDialog code example

Displaying data

o Subclasses of Symbol

o Using color

o ColorRamps

o Creating simple graphic elements

o Example: Make a new element, set its symbol

o Defining an element’s position

o Adding an element to the map (or layout)

o FeatureRenderers

o ScaleDependentRenderer

o RasterRenderer

o Storing layers on disk

o GxLayer object

o Example: Saving a layer from ArcMap

Queries and selections

o Object model overview

o Cursors and feature cursors

Page 6: Introduction to Programming Arc Objects Using VBA

o Three types of cursors

o Class activity: determining cursor type

o Creating a query filter

o SpatialFilter

o Returning a Search cursor

o Accessing records in a cursor

o Example: summarizing a cursor’s attributes

o Accessing selected features

o Working with selections

o Displaying a subset of features

o Working with attribute queries

Geometry and spatial analysis

o Feature geometry

o Geometry objects

o Points and multipoints

o Segments

o Polylines and polygons

o Envelopes

o Zooming in to a feature

o Spatial reference

o Creating new spatial reference

o Spatial analysis

o ITopologicalOperator

o IRelationalOperator

o IProximityOperator

o Area

o Length

o Getting the user X and Y

o Display transformation

o Convert display coordinates to map units

Data creation and editing

o Object model overview

o Name objects

o Converting feature classes

o Creating a new workspace

o Creating new data

Page 7: Introduction to Programming Arc Objects Using VBA

o Field and Fields classes

o IField and IFieldEdit

o Creating a Fields collection

o Creating a table or feature class

o Work with fields in a table

o Adding rows and values to a table

o Editing with a cursor

o Editing cursors

o Example: Updating incorrect values

o Example: Adding 100 rows to a table

o Adding a field

o Creating a domain

o Adding a domain to a geodatabase

o Applying domains

Geoprocessing

o Object model diagram overview

o What is geoprocessing?

o Geoprocessing framework

o Reasons to run geoprocessing tools from VBA

o GeoProcessor class

o Working with the GeoProcessor

o IGeoProcessor: Useful methods and properties

o Creating parameters for tools

o Executing a tool with ArcObjects

o Toolbox aliases

o Running custom geoprocessing tools

o Running multiple tools

o Working with messages

o Batch processing

Working with layouts

o Object model overview

o PageLayout

o Graphic and frame elements

o The Style Manager

o The style gallery

o Getting style items from the gallery

Page 8: Introduction to Programming Arc Objects Using VBA

o Referencing an individual style item

o Getting the item

o Adding a map surround

o Style Selector

o Printing a layout

o Exporting a layout

ArcObjects beyond VBA

o Working with ArcObjects

o Extending desktop applications

o Customization options

o Creating a custom component

o ArcGIS Engine

o ArcGIS Engine applications

o ArcGIS Server

o ArcGIS Server applications

o Author, publish, and use GIS services