3

I am designing a small ArcObjects (10.3.1) .Net Desktop Application that analyzes an .mxd for sde layers with broken connections and if possible fixes them. Everything works fine, however when retrieving the first Map from the MapDocument class via _pMapDocument.get_Map(i) it can be incredibly slow (where _pMapDocument is my MapDocumentClass object).

In trying to problem solve this I used the advice on the ArcObjects documentation page here, for initializing the ActiveView before working the the Map object.

When opening or creating a map document with the IMapDocument Open() or New() methods, you should always make subsequent calls to IActiveView::Activate() in order to properly initialize the display of the PageLayout and Map objects.

I found that if I call _pMapDocument.ActiveView.Activate(0) before retrieving the Map this call also can be incredibly slow but the subsequent call _pMapDocument.get_Map(i) is very fast.

Is it possible to retrieve the Map object in a faster way? And/or is there a way to identify a MapDocument that may take a long time to access its Map so that I can avoid hanging up my program? I have also tried circumventing the Map object as I just want to get the layers with _pMapDocument.Layer[i, j] but this also takes quite sometime on the first call. Many of the .mxds I am trying to fix are quite old, e.g. created from previous ArcMap versions 10.1, 10.2, etc., and I am wondering if this is an issue. Additionally I am a bit worried that the thing I am trying to fix, broken sde layers, is what is slowing down the retrieving of the map as perhaps when the map is opening it is continually looking for sde connections that no longer exist.

A more complete code snippet is listed below:

using ESRI.ArcGIS.Carto;

_pMapDocument.Open(sFilePath);
for (int i = 0; i < _pMapDocument.MapCount; i++)
{
    var pMap = _pMapDocument.get_Map(i);
    ILayer pLayer;
    for (int j = 0; j < pMap.LayerCount; j++)
    {
        pLayer = GetLayers(pMap.Layer[j], _dtLayers,  ref j);
    }
}
4
  • 1
    instead of a desktop application, try an add-in that reads the layer sources and fixes them for the open document. If this design won't work, at least it may help you figure out what's slowing it down.
    – Brad
    Commented Oct 21, 2016 at 19:51
  • 1
    Are you mxd's large, do they have many layers in them (i.e. > 10 layers)? If so may not be anything you can do?
    – Hornbydd
    Commented Oct 27, 2016 at 14:19
  • @Brad I have not pursued an esri-addin because many of the .mxds take so long to load (hours or not at all). One of the goals is to fix the issues in the .mxds that take forever to load without having the use ArcMap.
    – GeoSharp
    Commented Nov 2, 2016 at 17:27
  • @Hornbydd it depends, many of the .mxds are below 10 MB, with the majority below 3 MB. The number of layers is variable ranging from a few to a hundred or so.
    – GeoSharp
    Commented Nov 2, 2016 at 17:30

1 Answer 1

1

I'm not sure it would be any faster, but you could try creating a new GxMap, then setting IGxFile.Path to the mxd file path, then calling IGxFile.Open(). After that you should be able to access IGxPageLayout.PageLayout and loop through each of the maps by calling IPageLayout3.FocusNextMapFrame.

If that's still slow, I'd be curious if calling IGxDataElementHelper.RetrieveDEBaseProperties on GxMap can return a parent that has datasource names contained in its children, without trying to open the datasources the names reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.