I'm no expert with GIS development but I have created a tool that is used to interface with selected data in the Attribute Table that is currently open. Everything has been working fine since I wrote the tool but now all of a sudden my tool cannot find the CurrentLayer. My general question is "Is there a configuration setting that would cause this behaviour?"
Using ArcMap 10 on Windows 7. SQL backend, VS 2010 with C#.
In the code snippet below _map has zero Layers when I know they are there!
private IMap _map;
public MyEditorExtension()
{
_extensionStateService = Services.ExtensionStateService;
_map = ArcMap.Document.FocusMap;
_attributeWindow = (AddIn.FromID<AttributesWindow.AddinImpl>(ThisAddIn.IDs.AttributesWindow));
}
The code below should iterate all Layers in the map and find the correct layer based on the featureClassName string passed in, but because the map has no Layers (code above) it can't return the Layer that I need to edit. I'm 99.99% sure that this is a configuration problem because it worked and then it stopped. I can't even get my production Compiled AddIn to work either, but my colleague has no problem, however I'm the only one developing the Tool.
public static IFeatureLayer GetFeatureLayerByFeatureClassName(IMap map, string featureClassName)
{
IFeatureLayer result = null;
for (var i = 0; i < map.LayerCount; i++)
{
var layer = map.Layer[i];
var featureLayer = layer as IFeatureLayer;
if (featureLayer == null) continue;
var layerFc = featureLayer.FeatureClass;
var layerDs = (IDataset)layerFc;
if (layerDs.Name.Trim() == featureClassName.Trim())
{
//print the layer name in TOC..
result = featureLayer;
break;
}
}
return result;
}
MyEditorExtension()
a constructor? I don't recall ever putting any code in the constructor - usually code is in an event handler. see resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/…