This action might not be possible to undo. Are you sure you want to continue?
Arc Objects is the development platform for the ArcGIS family of applications such as Arc Map, Arc Catalog, and Arc Scene. Arc Objects is a framework that lets you create domain-specific components from other components. Arc Objects provides an infrastructure for application customization that lets you concentrate on serving the specific needs of your clients.
ArcObjects is a set of platform-independent software components, written in C++, that provides services to support geographic information system (GIS) applications on the desktop in the form of thick and thin clients and on the server. As previously stated, the language chosen to develop ArcObjects was C++; in addition to this language, ArcObjects makes use of the Microsoft Component Object Model (COM). COM is often thought of as simply specifying how objects are implemented and built in memory and how these objects communicate with one another. While this is true, COM also provides a solid infrastructure at the operating system level to support any system built using COM. On Microsoft Windows operating systems, the COM infrastructure is built directly into the operating system. For operating systems other than Microsoft Windows, this infrastructure must be provided for the ArcObjects system to function.
ArcGIS Desktop Use of the object is in one of the ArcGIS Desktop applications. ArcGIS Desktop applications provide a rich user experience, with applications containing many dialog boxes and property pages that allow end users to work effectively with the functionality of the object. Objects that contain properties that are to be modified by users of these applications should have property pages created for these properties. Not all objects require property pages.
ARCOBJECTS AND THE ARCGIS DESKTOP
is the development platform for Arc GIS Desktop. The Arc GIS Desktop systems each contain a configuration of applications,such as Arc Catalog, Arc Map, Arc Toolbox, and Arc Scene, and can host a variety of extension products such as ArcGIS Spatial Analyst,ArcGIS Geostatistical Analyst, ArcGIS 3D Analyst and others.
Arc Map , Arc Catalog
Map is used for mapping and editing tasks as well as map-based analysis. Catalog is used for managing your spatial data holdings, defining your geographic data custom schemas, and recording and viewing metadata.
Objects is built using Microsoft’s Component Object Model (COM) technology. is possible to extend Arc Objects by writing COM components using any COMcompliant development language. can extend every part of the Arc Objects architecture in exactly the same way as ESRI developers do.
Interpreting object model diagrams
Objects object model diagrams are based on the UML notation, an industrydiagramming standard for object-oriented analysis and design. The development environment,Visual Basic or other, lists all of the many classes and members but does not show the structure of those classes. These diagrams complete your understanding of the Arc Objects components.
Classes and objects
are 3 types of classes shown in the UML diagrams —abstract classes, co classes, and classes. A coclass represents objects that you can directly create using the object declaration syntax in your development environment. In Visual Basic, this is written with the Dim pFoo As New FooObject syntax. A class cannot directly create new objects, but objects of a class can be created as a property of another class or by functions from
inheritance defines specialized classes that share properties and methods with the super class and have additional properties and Line methods.
This diagram shows that a primary line (creatable class) and secondary line (creatable class) are types of a line (abstract class).
specifies that one object from one class has a method with which it creates an object from another class.
pole object might have a method to create a transformer ob
and hiding toolbars using the Customize dialog box 1. Click the Tools menu and click Customize. The Customize dialog box appears. You can also double-click any unoccupied area of any toolbar to display the Customize dialog box. 2. If it is not visible, click the Toolbars tab. The presence or absence of a check mark next to the toolbar name indicates its visible state.
Creating a new toolbar
the Toolbars tab of the Customize dialog box, click New. In the dialog box that appears, specify Chapter One Examples as the name of the new toolbar or use the default setting. Store the toolbar in the document by changing the name of the Save in dropdown list from Normal.mxt to Untitled or the name of the current project. Click OK. The newly created toolbar appears near the top of the application window.
Adding buttons to a toolbar created is Make sure the toolbar you just
visible. If it is not visible, display the Customize dialog box. Click the Commands tab of the Customize dialog box. Select the Pan/Zoom category from the Categories list. Scroll to the bottom of the Commands list. Select the Zoom in command and drag it to the toolbar. Release the command when the arrow cursor with a small box below it appears. Continue adding commands from the
Renaming a toolbar
the Toolbars tab, click the name of the toolbar whose name you want to change. Click the Rename button. In the dialog box that appears, specify My Own Tools as the new name. Note that you can only rename toolbars you’ve created. Click OK. If you decide not to rename the toolbar, click Cancel.
Removing buttons from a toolbar
sure the toolbar you just renamed, My Own Tools, is visible. If it is not visible, display the Customize dialog box. Drag some of the commands off the toolbar. Even though you’ve removed the buttons from the toolbar, they are still available in the Customize dialog box.
Adding a menu to a toolbar
sure the My Own Tools toolbar is visible. If it is not visible, display the Customize dialog box. Click the Commands tab and choose the Menus category from the Categories list on the left-hand side of the dialog box. In the Commands list at the right-hand side of the dialog box, click Selection. Drag and drop it to the left of the Zoom In button on the My Own Tools toolbar. Click Close in the Customize dialog box. Click Selection on the My Own Tools
Saving changes to a template
can save your work to a document or template. Changes saved to a document are specific to the document, whereas changes saved to a template will be reflected in all documents based on the template. Click the File menu and click Save As. Navigate to the Templates folder of the <installation directory>\bin folder. Click the Create New Folder button. Type a new name for the folder and doubleclick it. Type the template name, click ArcMap
WRITING MACROS IN VBA
can use the VBA integrated development environment to create macros to help you automate tasks you perform repeatedly or to extend the application’s built-in functionality. With the Visual Basic Editor, you can edit macros, copy macros from one module to another, rename the modules that store the macros, or rename the macros.
Creating a macro
the Tools menu, point to Macros, then click Macros. In the Macros dialog, type name in the Macro name text box and click Create. The application creates a new module named Module1 and stubs in the Sub procedure. Enter some code. Switch back to ArcMap by clicking the File menu, clicking Close, and clicking Return to ArcMap. Click the Tools menu, point to Macros, then
the Tools menu and click Customize. In the Toolbars tab, ensure that the toolbar is visible. Click the Commands tab and select the Macros category. Click the name of project in the Save in dropdown menu. The commands list to the right of the dialog box lists Project.Module1.Name. Drag the macro name to the toolbar you created. The macro appears with a default icon. To change its properties, right-click the icon. In the context menu that appears, click Change
Adding a macro to a toolbar
Calling built-in Commands
existing commands involves working with the ArcID module. Using the Find method, the code locates the unique identifier (UID) of the command in the ArcID module. Steps 1. Click the Tools menu, point to Macros, then click Visual Basic Editor. 2. In the Module1 module, create a Sub procedure with the following code: 3. Add the macro to a toolbar or menu. 4. Run the macro.
Code for FullExtent
Sub FullExtentPlus() Dim intAns As Integer Dim pItem As ICommandItem With ThisDocument.CommandBars Set pItem = .Find(ArcID.PanZoom_FullExtent) pItem.Execute intAns = MsgBox(“Zoom to previous extent?”, vbYesNo) If intAns = vbYes Then Set pItem = . Find(ArcID.PanZoom_ZoomToLastExtentBack) pItem.Execute End If End With
Creating a Command in VBA
invoked, a command usually performs some direct action without user intervention. A command is a type of UIControl. Click the Tools menu and click Customize. In the Customize dialog box, click the Commands tab and change the Save in dropdown menu to the name of your project or to Untitled. In the Categories list, select UIControls. Click New UIControl. In the dialog box that appears, choose UIButtonControl as the UIControl Type, then click Create and Edit.
Adding code for the UIControl
application adds an entry in the Object Box for the UIButtonControl and stubs in an event procedure for the UIButtonControl’s Click event. You’ll add code to this event to zoom the displa to the extents of the dataset. Private Sub UIButtonControl1_Click() Dim pDoc As IMxDocument Set pDoc = ThisDocument pDoc.ActiveView.Extent =pDoc.ActiveView.FullExtent pDoc.ActiveView.Refresh End Sub
Adding code for the UIControl
the Tools menu, click Customize, then click the Commands tab. In the Customize dialog box, click the Commands tab and change the Save in dropdown menu to the name of your project or to Untitled. In the Categories list, choose UIControls and drag the UIButtonControl you created to a toolbar. Close the Customize dialog box. Try the new command by zooming in on the map and clicking the button.
Creating a tool in VBA
Click the Tools menu and click Customize. 2. Click the Commands tab and change the Save in combo box to the name of your project or Untitled. 3. Choose UIControls from the Categories list. 4. Click New UIControl. 5. In the dialog box that appears, choose UIToolControl as the UIControl Type, then click Create and Edit.
Changing button properties
any toolbar and click Customize in the context menu that appears. Click the right mouse button to determine whether a context menu is available. Right-click the button whose properties you want to change. In the context menu that appears, click Change Button Image and choose an image. The image you chose appears on the face of the button. Close the Customize dialog box.
DEFINE THE ARCOBJECTS PROGRAMMING TASK 1. Describe the problem in Arc Objects terms. 2. Identify subtasks. 3. Decide where to write the code. 4. Search for a related sample or recommended methodology. LOCATE THE CORRECT OBJECT MODEL 1. Identify a subtask. 2. Extract keywords. 3. Search for the correct object model diagrams. 4. Review all related documentation. NAVIGATE THE OBJECT MODEL DIAGRAM
Arc Objects Problem Solving Guide
Writing Code Using Arc Objects
general, there are three ways to write Arc Objects code: • As a VBA macro in an ArcGIS application • As an ActiveX COM component such as a DLL or OCX • As a standalone EXE
Writing VBA macros in ArcGIS
• It’s fast and easy to create, test, and debug macros inside Arc Map and Arc Catalog. • The standard ESRI type libraries are already referenced. • Important global variables, such as the Application and Document, are available. • It’s simple to assemble UI forms using VBA and ActiveX components. • It’s straightforward to integrate VBA code with new Arc Objects UIControls. • It’s relatively easy to migrate VBA code to VB ActiveX DLL projects.
Writing ActiveX COM components
• They can be easily delivered to end users via custom setup programs. • You can hide Arc Objects code in a binary file and then deliver the functionality to end users with a setup program. • You can extend and customize virtually every aspect of the ArcGIS technology. Disadvantages • Have to acquire and use another COMcompliant development tool • Do not have direct access to the Application and ThisDocument global variables.
• You can use the ESRI Arc Objects Map control to simplify the embedding of Arc Objects functionality in your application. • You can design a highly customized user interface specific to your application. • You can quickly create small, lightweight applications. Disadvantages • You cannot take advantage of the extensive functionality that ESRI has built into the existing ArcGIS applications such as Arc Map or Arc Catalog.
Arc Map Core Objects
Arc Map Document
Application object directly manages a collection of objects, MxDocument, AppDisplay,SelectionEnvironment. When you first start Arc Map, the Application object is first created, and then it in turn instantiates all of the objects it manages. The IApplication interface provides access to the MxDocument object, the StatusBar object, the Templates object, the currently selected tool, the Visual Basic Editor. The IMxApplication interface provides access to the remainder of the objects the Application automatically creates, including AppDisplay,Paper Co Class, Printer, and
Arc Map document is called MxDocument; its role is to control the representation of data. The Arc Map application automatically creates this object when the application first starts. MxDocument specifically creates and manages the following objects: an empty Map, a PageLayout, the TOCCatalogView, the TOCDisplayView. You can obtain a reference to the
is the main application window, or the place where all data is drawn. Arc Map currently has two different views,data view and layout view Objects implement the IActiveView interface to establish themselves as views. The data view corresponds to a Map object, and the layout view corresponds to the PageLayout object. Either of these objects can be set as the document’s active view, and only one view is visible at a time.
Checking Type of View
following VBA code checks the type of active view: Dim pMxDoc As IMxDocument Set pMxDoc = Application.Document If TypeOf pMxDoc.ActiveView Is IMap Then MsgBox "Active View is a Map" ElseIf TypeOf pMxDoc.ActiveView Is IPageLayout Then MsgBox "Active view is the PageLayout" End If
Application object directly manages the life of all application extensions. Application extensions are those extensions registered in the ESRI MxExtension objects; All extensions are automatically created and destroyed in synchronization with an Application object. Use the IExtension interface to query the properties of an extension or implement this interface to create your own custom extension.
Getting Reference to an Extension
Public Sub CheckEditState() Dim pEditor As IEditor Dim pUID As New UID pUID = "esriCore.Editor" Set pEditor = Application.FindExtensionByCLSID(pUID) If pEditor.EditState = esriStateEditing Then MsgBox "Active Edit Session Present" End If End Sub
TOCDISPLAYVIEW AND TOCCONTENTSVIEW COCLASSES
views are tabs in the Arc Map table of contents. ArcMap ships with two contents views: display view and source view. The Display tab is the TOCDisplayView object, and the Source tab is the TOCCatalogView object. Developers can add new contents views by creating their own custom object that implements the IContentsView interface.
map document contains at least one Map object. Only one Map can have focus at a time, and this Map is called the focus map. IMxDocument provides access to all of the Map objects loaded in the document; IMxDocument::FocusMap returns a reference to the Map currently with focus, and IMxDocument.Maps returns the entire collection of Map objects. MapSurround objects are elements that are related to a Map. Types of map surrounds
properties related to creating and drawing selections. A SelectionEnvironment object is automatically created by the Application object when the application starts. Access to the Application object’s SelectionEnvironment is through IMxApplication::SelectionEnvironment.
Change Default Selection Color
Public Sub ChangeDefaultSelectionColor() Dim pMxDoc As IMxDocument Dim pMxApp As IMxApplication Dim pSelectionEnv As ISelectionEnvironment Dim pRgbColor As IRgbColor Set pMxApp = Application 'QI Set pMxDoc = Application.Document Set pSelectionEnv = pMxApp.SelectionEnvironment Set pRgbColor = New RgbColor pRgbColor.Red = 255
FEATURE RENDERER A feature renderer is a method for drawing feature layers. Use symbols and colors to visually display features, possibly based on one or more attributes. Types of feature renderers: • SimpleRenderer uses the same symbol for each feature. • ClassBreaksRenderer allows classes of numeric attribute values to be defined. A different symbol is specified for eac class. • UniqueValueRenderer uses a different symbol for each unique attribute value. • ProportionalSymbolRenderer modifies the size of the symbol in proportion to an attribute from a field. • DotDensityRenderer displays a scattering of marker symbols in polygon features, the density of which reflects the value of an attribute.
Get a Feature Renderer
To get to a feature renderer object in Arc Map from a layer, QI to IGeoFeatureLayer and get the Renderer property.
simple renderer is the default renderer object when a new feature class is loaded.
' Check if the layer is a feature layer If Not TypeOf pLayer Is IGeoFeatureLayer Then Exit Sub Set pGeoFeatureLayer = pLayer ' Check if there is a simple renderer and get a reference to it If Not TypeOf pGeoFeatureLayer.Renderer Is ISimpleRenderer Then Exit Sub
Objects that support the IColor interface allow precise control over any color used within the ArcObjects model. You can get and set colors using a variety of standard color models—RGB, CMYK, HSV, HLS, and Grayscale. RGBCOLOR COCLASS To get and set the red,green, and blue components of a color Interface- IRGBColor CMYKCOLOR COCLASS Colors can be specified for output in terms of Cyan, Magenta, Yellow, and Black. Interface- ICMYKColor
Types of Symbols
uses three categories of symbols to draw geographic features:
symbols, Line symbols, Fill symbols.
application developers to easily draw graphics on a variety of output devices. Allow you to render shapes stored in realworld coordinates to the screen, the printer, and export files. Use the IDisplay interface to draw points, lines, polygons, rectangles,and text on a device. Access to the display object’s DisplayTransformation object is provided by this interface.
To Pan Map Display
Private Sub UIToolControl1_MouseDown(ByVal button As Long, _ByVal shift As Long, ByVal x As Long, ByVal y As Long) Dim pScreenDisplay As IScreenDisplay Dim pActiveView As IActiveView Dim pMxDoc As IMxDocument Set pMxDoc = Application.Document Set pActiveView = pMxDoc.FocusMap Set pScreenDisplay = pActiveView.ScreenDisplay pScreenDisplay.TrackPan
the map-to-device transformation Defines how real-world coordinates are mapped to an output space. Map’s DisplayTransformation has a SpatialReference object that manages the Map’s current coordinate system. A reference to the SpatialReference object is set through IDisplayTransformation::SpatialReference.
prepare a transform for use, follow these steps: 1. Set the full map extent with the Bounds property. 2. Set the visible map extent (zoom rectangle) with the VisibleBounds property. 3. Set the output area of the device using the DeviceFrame property. 4. Set the resolution of the output device using the Resolution property.
Rubber Band Objects
interface, allow the user to digitize geometries on the display using the mouse— either to create whole new geometry objects or to update existing ones. Examples-Dragging an envelope, forming a new polyline, or moving a point. IRubberband interface has two methods TrackExisting Move existing geometries TrackNew Create new geometries
Private Sub UIToolControl1_MouseDown(ByVal button As Long, _ ByVal shift As Long, ByVal x As Long, ByVal y As Long) Dim pRubberLine As IRubberBand Dim pGeom As IGeometry Dim pMXDoc As IMxDocument Set pMXDoc = ThisDocument Set pRubberLine = New RubberLine Set pGeom=pRubberLine.TrackNew (pMXDoc.ActiveView.ScreenDisplay, Nothing) End Sub
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.