Adv_GISArcObjects - 11 VBA and ArcObjects Programming Week 1 Spring 2008 Advanced GIS.

Slides:



Advertisements
Similar presentations
5-1 5 Tour of ArcMap and ArcCatalog ArcGIS for Assessors 1.
Advertisements

Geo GIS Practicuum Introduction to ArcGIS 8 Exercise 5 - ESRI Virtual Campus Chapters 1-2, ArcGIS Methods …
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Using VB with MS Applications R. Juhl, Delta College.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 12: Enhancing Excel with Visual Basic for Applications
COMPREHENSIVE Windows Tutorial 3 Personalizing Your Windows Environment.
Annotation & Nomenclature By Corey Fortezzo for PG&G GIS Workshop, 2010.
Appendix B: Customizing In this unit… ► Review ► Overview ► Adding, Removing Buttons ► Changing Button Properties ► Visual Basic.
Technical Support: (989) GIS and Mapping Procedures in ArcMap 9.x Creating an ArcMap Project Editing an ArcMap Project Printing an ArcMap Project.
Intro to ArcMap Customization with Visual Basic  Create your own toolbars, buttons, interactive tools, and programs  Runs behind the scenes in ArcMap.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
ArcView / Avenue / ArcGIS Customization. Basic Customization in ArcView 3.x Sources for scripts and extensions Installing an extension Adding and running.
Tuesday Session 2 – Intro to ArcMap Starting Arc Map – Empty Map – Map Template – Project Data View – Display – Source – Selection Layout View – Draft.
Using the Visual Basic Editor Visual Basic for Applications 1.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 1 Getting Started With Dreamweaver. Explore the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
ModelBuilder at ArcGIS 9.2 Lyna Wiggins Rutgers University May 2008.
GISC 6382 Applied GIS UT-Dallas Briggs 1 Customizing ArcGIS Spring 2008.
GIS Data Models Components of a GIS Map Common Data Models.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Introduction To ArcMap ArcMa p. ArcMap is a Map-centric GUI tool used to perform map-based tasks Mapping –Create maps by working geographically and interactively.
Google Earth How to create a Google Earth Tour and place it in your Wiki.
Introduction to ArcGIS Add-Ins Exercises GIS/LIS Conference, 2014 Rochester, MN.
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Adv_GISArcObjects - 11 VBA and ArcObjects Fall 2003 Advanced GIS.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
A New Generation GIS for the Classroom ArcGIS 9.0 A New Generation GIS for the Classroom.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
1 CA201 Word Application Increasing Efficiency Week # 13 By Tariq Ibn Aziz Dammam Community college.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
ArcGIS 9 ch 9 Edited 06/14/05 1 Getting GPS Data into ArcGIS At this point, you have successfully collected, corrected, and exported your data using Pathfinder.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Session 1 SESSION 1 Working with Dreamweaver 8.0.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Introduction of Geoprocessing Topic 7a 4/10/2007.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
ATN GIS Support ArcGIS: ArcMap Data View.
Copyright © 2010 Wolters Kluwer Health | Lippincott Williams & Wilkins Introduction to Windows Chapter 2.
© Paradigm Publishing Inc. MICROSOFT WINDOWS XP MAINTAINING FILES AND CUSTOMIZING WINDOWS Section 2.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
OCC Network Drives  H:\  P:\ 
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Creating an Application System Using Macros, Wizards, and the Switchboard.
ATN GIS Support ArcGIS: ArcCatalog.
Module 4: Creating a Quick Map Sarah Hartsburg GIS Tech, Contractor for NPS Fire GIS
Visual Basic CDA College Limassol Campus Lecture:Pelekanou Olga Semester C Week - 1.
Chapter 23. Copyright 2003, Paradigm Publishing Inc. CHAPTER 23 BACKNEXTEND 23-2 LINKS TO OBJECTIVES Record, Run, Pause, and Delete Macros Record, Run,
ArcGIS: ArcCatalog. Agenda The ArcCatalog Interface General ArcCatalog ▫Navigating directories ▫Preview data ▫View metadata Advanced ArcCatalog ▫Modifying.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Introduction of Geoprocessing Lecture 9 3/24/2008.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Scale is the relationship between the size of features on a map and the size of the corresponding objects in the real world. Scale is commonly expressed.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
DRAWING LINES To draw lines click View in the Main Menu Toolbar -> Toolbars and check the Editor option. The Editor toolbar will appear amongst the toobars.
Geography 385 Introduction to ArcGIS Web Application Design
1. Introduction to Visual Basic
Presentation transcript:

Adv_GISArcObjects - 11 VBA and ArcObjects Programming Week 1 Spring 2008 Advanced GIS

Adv_GISArcObjects - 12 Why learn programming ? Because, there are three types of GIS jobs in the market.... Logon to monster.com and type “GIS programmer” And you will find the pay scale….

Adv_GISArcObjects - 13 Object-Oriented Programming Object has property and behaviors (methods). Lots of objects are buttons, tools, windows, and dialog boxes. Object.Method –Table.AddRecord –Tree.Grow(10) /argument, parameter –Tree.Create /first create a tree, then –Tree.GrowBranch /then, grow branch from the tree –Branch.GrowApple /apple grown from branch. –Boy.Eat(AnApple)

Adv_GISArcObjects - 14 Visual Basic for Application (VBA) A simplified version of Visual Basic, loaded with ArcGIS, embedded within applications. Use functions in ArcGIS Code organized in Procedures – a procedure includes instructions. Procedure can be linked to each other, by calling others. Events makes procedure run.

Adv_GISArcObjects - 15 ArcObjects and ArcGIS ArcMap and ArcCatalog are built with ArcObjects –Each GIS part is a programmable object –Users and programmers use same objects Data frames, layers, features, tables, symbols, points, lines, polygons, records, fields, colors are ArcObjects

Adv_GISArcObjects - 16 ArcObjects There are 2,700+ classes and 2,000 interfaces documented in several object model diagrams. With such extensive collection of classes, you can create many customized applications to extend ArcGIS’s functions. “Where to begin with?” is the major difficulties faced by GIS programmers. –Problem solving strategy help you glide through the real-world ArcObjects programming tasks. –Three parts of problem-solving guides

Adv_GISArcObjects - 17 I: Define the ArcObjects Programming Tasks Describe the problem in ArcObjects terms Identify subtasks Decide where to write the code Search for a related sample of recommended methodology Identify a subtask Extract keywords Search for the correct object model diagrams Review all related documentation II: Locate the correct object model Review the structure of the object model diagram Trace the flow between classes and assemble code III: Navigate the object model diagram

Adv_GISArcObjects - 18 Describe the problem in ArcGIS terms For example: Add a dataset called States to ArcMap can be described as: –Access the States feature class from a personal geodatabase and add it to ArcMap. A two-step approach illustrate the procedures.

Adv_GISArcObjects - 19 Customize Toolbars Open a ArcMap screen (Start |Programs | ArcGIS |ArcMap) You want to start with “A new empty map”. Add theme from c:\esri\esridata\usa\ (STATES, Drainage, lakes, rivers and roads) Once your themes are in the project, practice the functions of ArcMap ( –Zoom In/Out, –Pan, –Select Feature, –Identify, –Measure ? (you may get degrees as distance) change DataFrame Properties’ setting of Display Unit to “Miles”

Adv_GISArcObjects Showing/Hiding toolbars Double-click any unoccupied area of any toolbars to display the Customize dialog box (or from Tools|Customize..) The presence of a check mark next to the toolbar name indicates it is present. In the Toolbars tab of the Customize dialog, click New. In the Tools Name area type in “My personal tools” and Save in “Untitled” (since you haven’t saved your project yet). If you save the personal tool into “Normal.mxt”, then it will become a default tool for everyone who use this machine. We don’t want to do so. Simply save it to “Untitled” to avoid confusion to other users. Click OK

Adv_GISArcObjects Adding more tools to your personal tool box Adding buttons and menus to your personal tool by selecting commands (click Command tab to switch to Command window) dragging to “My personal tools” toolbar. With category of Selection open (Command | Selection), drag commands to “My personal tools” (drag Buffer Selection and Hyperlink to the window, if Category is “Selection”) Practice putting different menu and commands on your personal toolbar. You can also remove them by dragging out of the box. Click Close to close the customize window. Save file in your own folder (if you don’t have one, create one in G drive)

Adv_GISArcObjects Writing Macros in VBA You can use VBA integrated development environment (IDE) to create macros to help you automate tasks you perform repeatedly With the VB Editor you can edit macros, copy macros from one module to next, rename modules that store macros. Click the Tool menu, point to Macros, then click Macro. In the Macro dialog, type MyZoomIn as name and click “Create” (this will take you to the VB screen and you are ready to create a customized tool)

Adv_GISArcObjects Sub MyZoomIn() ' ' macro; MyRoomIn ' Dim pDoc As IMxDocument Dim pEnv As IEnvelope Set pDoc = ThisDocument Set pEnv = pDoc.ActiveView.Extent pEnv.Expand 0.5, 0.5, True pDoc.ActiveView.Extent = pEnv pDoc.ActiveView.Refresh End Sub Envelopes are the rectangular window that contain a specific element. All Geometry objects have an envelope defined by the XMin, XMax, YMin, and YMax of the object. Envelopes can also serve as the viewing area for a particular view screen or data frame.XMinXMaxYMinYMax Code window ArcMap Doc ThisPredefined variable-is the Idocument interface to the MxDocument object ActiveView property provides an IActiveView interface that links the document data to the current screen display of that data

Adv_GISArcObjects Run Macro Go to File | Close Return to ArcMap In ArcMap, go to Tools |Macro and select Module1.MyZoomIn macro and click Run (make sure your macro settings is in Normal) (Alt + F8) The display zoomed in 50% smaller.

Adv_GISArcObjects Add Macro to a toolbar Go to Tools | Customize. In the Toolbar tab, make sure “My personal Tool” is still there Click Command tab and select Macros category. Select your macro (MyRoomIn) and drag to ”My Personal Tool” bar A default icon appears. To change image, right-click on this icon and a context menu shows, go to Change Button Image and select one from the panel (smiling face,ok?) Close the Customize dialog box Click the smiling face to run the macro Right-click on smiling face, select View Source to modify your code to 0.75 from 0.5 for zoomin ratio

Adv_GISArcObjects Exercise - 1 Create a new Macro named: MyRoomOut in Module1 Hint: copy code from codewindow (from the beginning of the Sub to the End Sub, and paste below the existing code. Rename the copied Sub to “MyZoomOut” and change line: –pEnv.Expand 0.5, 0.5, True to –pEnv.Expand 2.0,2.0,True Add this macro to My Personal Tool and run it

Adv_GISArcObjects UIControls – User Interface Controls UIButton - Save UITool - Pan UIComboBox UIEditBox Code is required for UI to work.

Adv_GISArcObjects Project, Code module and Procedure

Adv_GISArcObjects Project/Code Module/Procedure 3 types of projects: –Map documents (.mxd) –Base templates (.mxt) Normal template (Normal.mxt) Code modules – –ThisDocument, you may write code for any UIControls that you make in a particular project Procedure – –Code is organized into procedures

Adv_GISArcObjects Procedures 4 types of procedures: –Event, subroutine, function and property –Event : correspond to user actions, such as Click, which will execute the codes once it is clicked and three other types of codes will be called to work Public/Private: “Private” procedure can only be called within same code module where “Public” procedures can be called by other code modules.

Adv_GISArcObjects InputBox/MsgBox InputBox and MsgBox are two fundamental message receiving and conveying methods used in the beginning of this class. Inputbox (“Message here”, “Title Here”.) MsgBox (“Message Here”, “Title here”) You may not use () for these boxes