Converting ESRI ITable to .NET DataTable

April 30, 2008

Ran into this interesting ArcObjects utility class yesterday.
To convert records of an ITable to an inMemory DataTable, use ESRI.ArcGIS.Utility.Converter.ToDataSet.

This works really well for data viewing.
However this interface seems to be now depracated and replaced with ESRI.ArcGIS.ADF.
The ToDataSet method is missing in the new interface.

Sample code:
ITable table = featureWorkspace.OpenTable(tableName);
IRecordSetInit recordSetInit= new ESRI.ArcGIS.Geodatabase.RecordSetClass();
recordSetInit.SetSourceTable(table, new QueryFilterClass());
IRecordSet recordSet= recordSetInit as IRecordSet;

System.Data.DataSet netDS = ESRI.ArcGIS.Utility.Converter.ToDataSet(recordSet);


Five Best Practices for Maintaining an ArcSDE Geodatabase

April 29, 2008

ArcSDE team has a very good blog posting on best practices for maintaining an SDE geodatabase. A must read for all users who are involved with working and maintaining geodatabases.

Here is the link
(http://blogs.esri.com/Dev/blogs/geodatabase/archive/2008/04/03/Five-Best-Practices-for-Maintaining-an-Enterprise-Geodatabase.aspx)


ArcMap: Working with multiple DataFrames

April 26, 2008

(From ESRI) The viewer window is a new window that was introduced at 9.2 to enable users to work with one data frame at multiplescales. In the 9.2 release if you opened a viewer window and then activated a different data frame in your map document, the viewer window was automatically closed. In Service Pack 2, ESRI has enhanced viewer windows so that you can use them to view inactive data frames. Now if you activate a different data frame while a viewer window is open, that viewer window remains on-screen, enabling you to work with multiple data frames side by side.

When you work with an inactive data frame in a viewer window, you can easily make the viewer show the same location that is currently displayed in the active data frame in the main ArcMap window. Similarly, you can update the location shown in the active data frame in the main ArcMap window to match the location shown in any of your viewer windows.

The ability to work with multiple data frames side-by-side in ArcMap can be useful for analysis, historical change assessment, data evaluation, and other applications where you want to be able to see different datasets for the same area side by side, as opposed to working with all the data in one data frame, or working with multiple map documents.

Pictures and more details demonstrating this can be found here

http://downloads.esri.com/support/downloads/other_/Whats_New_In_ArcGIS_92_Service_Packs-v5.pdf


Add layer to Map with “autoArrange”

April 16, 2008

One of the very common operations programmers do in ArcObjects is adding a layer to the Map. To do this there are two ways, one using IMap.AddLayer or IMapLayers.AddLayer.

IMap.AddLayer adds the new layer on the top of all the layers in the map. This is not very useful as we normally want the point layers at the top followed by polyline followed by polygon layers. Adding polygon layers at the top would mask all other layers below.

IMapLayers.AddLayer is preferable because it has an option to autoArrange the newly added layer in the table of contents. If autoArrange is set to TRUE, the layer is added in the proper position as by its weight specified via ILayerPosition::LayerWeight. By default, this means that the layers are sorted by layer type – Annotation layers on top, followed by Point geometry layers, Polyline geometry layers, and at the bottom Polygon geometry layers.


Unit Testing with ArcGIS

January 14, 2008

As a part of writing any unit-test to test the add-ins (buttons/tools/extensions) and their behavior in ArcMap, it is essential to automate starting ArcMap and running the commands. Here is a good article on how to automate ArcMap.


Changing Bitmap on BaseCommands/Tools at runtime

October 26, 2007

A common scenario that ArcObjects developers come across is creating a button or tool in ArcMap whose image changes when clicked.

Example: Say you wish to create a “LogOn” button whose bitmap needs to change to “LogOff” bitmap once the user has logged in.

Just setting base.m_bitmap to the new bitmap does not update the bitmap in ArcMap. Instead you need to use the BaseCommand.UpdateBitmap method.

Per ESRI .Net documentation:
UpdateBitmap changes the Bitmap for the command. Call this method to update the icon used for the command at runtime, after the command has already been instantiated.


IWorkspaceFactorySchemaCache

October 17, 2007

When working with bulk editing or editing operations that might cause performance hits, try using IWorkspaceFactorySchemaCache and enable schema caching. This is supposed to improve the performance. Some people have reported improved performance (3 times) on even DifferenceCursors when enabling schema cache.