Customizing Arc Gis Desktop
-
Upload
api-3747051 -
Category
Documents
-
view
1.979 -
download
0
Transcript of Customizing Arc Gis Desktop
![Page 1: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/1.jpg)
Customizing theArcGIS DesktopJeremiah Lindemann
ESRI DenverAGIC 2005 Conference
Prescott, AZ
![Page 2: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/2.jpg)
VBA Customization• Customize the interface to suite your needs
without writing code• Use VBA to extend ArcMap/ArcCatalog• Create custom
user forms, buttons and tools
• Automate workflows
• Subject of this seminar
![Page 3: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/3.jpg)
Workshop overview
• The VBA development environment– Customize dialog box
• Changing the UI without writing code!
– Visual Basic Editor• Where to write code
• Using developer samples• Introductory look at ArcObjects (if time allows)• Questions
![Page 4: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/4.jpg)
The VBA development environment• Similar environment for all applications that use
VBA– Customize dialog box: Interface customization– Visual Basic Editor: Writing code
Customize dialog box
Visual Basic Editor
![Page 5: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/5.jpg)
ArcGIS commands• Toolbars and menus contain commands• Commands are buttons, menus, macros, and
UIControls• Each command has associated code
ToolbarToolbar
CommandsCommands
![Page 6: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/6.jpg)
Using the Customize dialog box• Open the dialog to put the interface in design
mode• With the Customize dialog box open, you can …
– Rearrange or remove existing commands– Add new toolbars and commands– Change command properties
![Page 7: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/7.jpg)
The Customize Dialog
• Toolbars tab– Turn toolbars on and off, create new
![Page 8: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/8.jpg)
The Customize Dialog
• Command tab– Drag and drop commands to existing toolabars
![Page 9: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/9.jpg)
Using the Customize dialog box
• Commands are organized into categories• All ArcMap or ArcCatalog commands are here
– Some that are not on the interface by default• Drag commands onto toolbars or menus
Command Categories
Commands
![Page 10: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/10.jpg)
Setting control properties• Customize dialog box must be open• Right-click a control to view and change properties • Characteristics that define appearance
– Name– Image– Display text or
image– Begin a group
![Page 11: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/11.jpg)
Accessing your customizations• ArcMap has three levels of storage• Templates are read in order on startup
• ArcCatalog only uses the Normal template
This Document
Base Template
Normal Template
Affects all documents using this template
Affects this document
Affects all documents
![Page 12: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/12.jpg)
Storing your customizations• All customizations are saved
– Normal template, Base template, or the current document
• Current map overrides any templates– For example, controls can be added or removed
Save in: Normal.mxt
![Page 13: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/13.jpg)
Instructor Led Demo
• Using the Customize dialog box to …– Rearrange interface commands– Create a new toolbar– Add existing commands to the interface– Create a new UIControl– Change command properties– Reset a toolbar to its original appearance
![Page 14: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/14.jpg)
The Visual Basic Editor
Code ModulesCode Modules ProceduresProcedures
ProjectExplorerProject
Explorer
ProjectsProjects
![Page 15: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/15.jpg)
Project Explorer: Organizes projects (levels of customization)
Project: Folder that stores modules (e.g., Normal.mxt)
Module: Document that stores code
Procedure: A block of code (e.g., macros)
Statement: A line of code
Understanding ArcMap software’s code storage
ModuleModule
ProcedureProcedureStatementsStatements{
![Page 16: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/16.jpg)
Writing Visual Basic statements
• Carry out actions• Written inside procedures• May have arguments
– Multiple arguments are separated with commas– Some arguments are optional
Private Sub ShowMsgBox()BeepMsgBox "ESRI"
End Sub
![Page 17: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/17.jpg)
• InputBox to get information
• MsgBox to report a message
• Combine (concatenate) strings with & …• Get the Date or Time …
Some common Visual Basic functions
MsgBox "ArcMap is Great!"
MsgBox "The date is " & Date
MsgBox "The time is " & Time
MsgBox "The date and time is " & Now
InputBox "Enter the new Landuse Code: "
![Page 18: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/18.jpg)
Creating a new command
• UIControls category– User-created commands
• Four types– Button– Tool– EditBox– ComboBox
![Page 19: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/19.jpg)
Event Procedures
MouseDownMouseDown
ChangeChangeClickClick
ToolTipToolTip
![Page 20: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/20.jpg)
Running an event procedure
• Controls have a predefined set of events – You choose which ones to code
• When an event is fired, the associated code executes
![Page 21: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/21.jpg)
Examining a control’s source code
• Commands have events (e.g., Click, Double-click, MouseUp, KeyDown, KeyUp)
• Code runs when its corresponding event occurs
![Page 22: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/22.jpg)
Procedure box
Choose an event in the Procedure box
Wrapper lines are added automatically
Navigating event procedures in a module
A
MsgBox "Hi!"
Write code to run when UIButtonControl1 is clicked
![Page 23: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/23.jpg)
The ThisDocument module
• Contains code associated with a document– Normal template– Current map document (mxd)– Base template (optional)
• Customize at any level
![Page 24: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/24.jpg)
Creating a new module
• Module (standard module): Contains standalonecode
• Class module: Contains a class definition • UserForm: Contains code and layout for a form
![Page 25: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/25.jpg)
Running a subroutine or function procedure
• No event to cause code execution• Must call the procedure
– Macro menu: Interface– Call statement: Code
![Page 26: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/26.jpg)
Adding a macro to a toolbar
• Macros category of the Customize dialog• Macro becomes a button on the toolbar
– Edit the control’s properties
![Page 27: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/27.jpg)
What is a Form?• It’s a module• Window of controls + associated code
WindowWindow
Associated CodeAssociated Code
![Page 28: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/28.jpg)
Placing Controls on the Form
• Click and drag – from toolbox to window• Given default properties
![Page 29: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/29.jpg)
Placing Controls on the Form
• Click and drag – from toolbox to window• Given default properties
![Page 30: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/30.jpg)
Placing Controls on the Form
• Click and drag – from toolbox to window• Given default properties
![Page 31: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/31.jpg)
Placing Controls on the Form• Click and drag – from toolbox to window• Given default properties
![Page 32: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/32.jpg)
Placing Controls on the Form• Click and drag – from toolbox to window• Given default properties
![Page 33: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/33.jpg)
Changing Properties
![Page 34: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/34.jpg)
Writing the Code• Tie code to the object event procedures• Objects found on left, events on right
ClickClick
InitializeInitialize
![Page 35: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/35.jpg)
Instructor Led Demo: Creating a Form• Create a form
– Convert Celsius to Fahrenheit – (txtCelsius.Text * 9 / 5) + 32
• Show form with a button
![Page 36: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/36.jpg)
Workshop overview
• The VBA development environment– Customize dialog box
• Changing the UI without writing code!
– Visual Basic Editor• Where to write code
• Introductory look at ArcObjects• Using developer samples
![Page 37: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/37.jpg)
Finding Existing Code
• Tips– Source code– Copy and paste into VBA
• Tools– Compiled code (.dll)
• Follow Instructions!
![Page 38: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/38.jpg)
Demo: Using a developer sample• Tip
– Add a layer file to ArcMap• EDN Online:
– http://edn.esri.com
![Page 39: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/39.jpg)
cccccccccccccc
Object Oriented
Map ArcObjectLayer: ILayer
LayerCount: Double
Name: String
ReferenceScale:Double
SelectionCount: Double
AddLayer(ILayer)
ClearLayersExtent: IEnvelope
FullExtent: IEnvelope
GraphicsContainer: IGraphicsContainer
Selection: ISelection
Clear
Refresh
• Object members:•Properties ( )•Methods ( )
![Page 40: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/40.jpg)
Interfaces
Map ArcObjectLayer: ILayer
LayerCount: Double
Name: String
ReferenceScale:Double
SelectionCount: Double
AddLayer(ILayer)
ClearLayers
IMap
IActiveView Extent: IEnvelope
FullExtent: IEnvelope
GraphicsContainer: IGraphicsContainer
Selection: ISelection
Clear
Refresh
InterfacesInterfaces
• Logical grouping of properties and methods
![Page 41: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/41.jpg)
Interfaces
Map
MapUnitsAddLayer
Name
RefreshFullExtentIActiveView
IMap
• Communicate with an object through its interface• What interface will you use?
– It depends on what property or method you want
![Page 42: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/42.jpg)
Locating Interfaces
![Page 43: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/43.jpg)
• To reference an existing ArcObjects– Can not reference it directly– Must think about where it resides in object model
Relationship between ArcObjects
MxDocument
Map*
*
FeatureLayer
Layer
• To reference a layer in ArcMap–What is your starting point?
![Page 44: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/44.jpg)
Starting points for writing code• VBA offers two preset variables
– Application references the ArcMap application– ThisDocument references the MxDocument
![Page 45: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/45.jpg)
Two steps to writing ArcObjects code
Step One: DimensionStep Two: Set
Map
LayerAddLayer
Name
RefreshFullExtentIActiveView
IMap
MxDocumentFocusMapIMxDocumentPageLayout
Application
DocumentIApplication
![Page 46: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/46.jpg)
ArcObjects example
MxDocumentMxDocument
Map (Data Frame)Map (Data Frame)
LayerLayer
![Page 47: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/47.jpg)
Advanced Desktop Customization
• Use VB6, VC++ or .NET to extend Desktop applications and geodatabase
• Create custom componentsto enhance functionality
Edit TaskEdit Task
CommandCommand
Table of Contents TabTable of Contents Tab
![Page 48: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/48.jpg)
Using a .DLL
• "Dynamic Linked Library"• Save the .DLL onto your hard drive• All samples already installed in:
– C:\Program Files\ArcGIS\DeveloperKit\samples• In the Customize Dialog box in ArcMap,
choose “Add from file”– The .DLL will be added as a command under the
“Developer Samples” category– Drag and Drop this command to any toolbar
![Page 49: Customizing Arc Gis Desktop](https://reader033.fdocuments.us/reader033/viewer/2022050804/5528bc474a7959c93d8b4838/html5/thumbnails/49.jpg)
Useful Resources• ESRI Developer Network (EDN):
– http://edn.esri.com/• Documentation• Samples• Discussion forums
• Web based and instructor led training– Introduction to Programming ArcObjects with VBA: 5-
day instructor led course• Book: Getting to Know ArcObjects