I've created many custom tools in ArcMap, with most of them using the fuctionality where they are grayed out until the user starts an edit session. The code I have always used is like this:
public class ToFromTool_AddIn : ESRI.ArcGIS.Desktop.AddIns.Button
{
private ESRI.ArcGIS.esriSystem.UID editorUID = new ESRI.ArcGIS.esriSystem.UIDClass();
private ESRI.ArcGIS.Editor.IEditor3 m_editor;
protected override void OnUpdate()
{
Enabled = m_editor.EditState != esriEditState.esriStateNotEditing;
}
}
It's been a while since I've created a new ArcMap tool, but for some reason the new tool I have created will not activate when I start an edit session. There must be something I have missed, but I cannot figure it out.
Any ideas of what I need to check??
Solved! Go to Solution.
Hi Sean,
Yes, I had onDemand = false. What I was doing was recreating a tool that already existed. So it had a new GUID and version #, yet everything else was the same to facilitate easily copy/pasting code from one to the other. In the end what fixed it was deleting the original .esriAddIn file and replacing it with the new one.
My setup for testing was to load the original tool through a network path, and then load the new tool through the local AddIns folder as I was testing it with VisualStudio. Both tools were appearing in the toolbar, but only the original was working properly.
Not sure why I had to delete the original one to finally get things working, but it is all working now.
Thanks,
Hey Brian,
You'll need to add onDemand="false" to your controls definition in the config.esriaddinx file.
This loads the code behind the tool when the tool is instantiated rather than when its clicked on.
Hi Sean,
Yes, I had onDemand = false. What I was doing was recreating a tool that already existed. So it had a new GUID and version #, yet everything else was the same to facilitate easily copy/pasting code from one to the other. In the end what fixed it was deleting the original .esriAddIn file and replacing it with the new one.
My setup for testing was to load the original tool through a network path, and then load the new tool through the local AddIns folder as I was testing it with VisualStudio. Both tools were appearing in the toolbar, but only the original was working properly.
Not sure why I had to delete the original one to finally get things working, but it is all working now.
Thanks,