Lesson 5 - Intro to Programming ArcObjects (Week 1)
In this exercise, the most important skills that I obtained were how to work
with Object Model Diagrams and the ArcGIS Developer Help. In order to write the
code for each of the two practice exercises and the Zoom menu tool, working
knowledge of the OMDs and Developer Help came in handy.
For Practice Exercise 1, we used code to collapse all of the active data layers in the Table of Contents in the map document. Doing so required the pMap.Expanded command and a Boolean value to represent whether or not the data frame was collapsed or expanded (+ or -). This was a rather simple exercise that only required several lines of code.
For Practice Exercise 2, we used FieldCount to query the number of fields present in the attribute table of the second layer. This was also relatively simple, and a Message Box returned the number of fields present to the user. I originally messed up by having '1' instead of '0' in the pMap.Layer() line of code, but once I fixed that, it returned the number of fields correctly.
The final part of the project implemented a Zoom tool with eight separate custom settings available at the click of a button in a drop-down menu. I initially had the fractions reversed (thinking that zooming out 200% would be a result of implementing a 1/2 code) but the reason for that was that it was cutting the scale in half, making the extent smaller in size. This made sense, as 1:5000 would show half the area that 1:10000 would, so I was sure to make the change to 1*2 in my code. This was a simple exercise to help understand about customizing toolbars in ArcMap and adding functions with tool buttons and drop-down menus.