Still struggling with this. Is there some reason why the tool would not trigger the OnCreateFeature event? It certainly works through the Editor, as it builds an undo-able Edit Operation...Here's my code that sets up the extension and the event handlers. This is pretty much out-of-the-box SDK stuff. Still, perhaps I'm doing something wrong?using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Editor;
using ESRI.ArcGIS.Geodatabase;
namespace editorExtension
{
[Guid("7ec485d2-15af-43e1-ae3f-8c55c93e0317")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("editorExtension.ncgmpEditorExtension")]
public class ncgmpEditorExtension : ESRI.ArcGIS.esriSystem.IExtension, ESRI.ArcGIS.esriSystem.IExtensionConfig
{
private Editor m_Editor;
private IWorkspace m_EditWorkspace;
private bool m_DatabaseIsValid = false;
private sysInfo m_SysInfo;
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType);
//
// TODO: Add any COM registration code here
//
}
[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType);
//
// TODO: Add any COM unregistration code here
//
}
#region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
EditorExtensions.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
EditorExtensions.Unregister(regKey);
}
#endregion
#endregion
#region "IExtension Implementations - Event Handlers setup here"
public string Name
{
get
{
return "AZGS/NCGMP Extension";
}
}
public void Shutdown()
{
// Remove the event handlers
m_Editor.OnCreateFeature -= new IEditEvents_OnCreateFeatureEventHandler(m_Editor_OnCreateFeature);
m_Editor.OnChangeFeature -= new IEditEvents_OnChangeFeatureEventHandler(m_Editor_OnChangeFeature);
m_Editor.OnDeleteFeature -= new IEditEvents_OnDeleteFeatureEventHandler(m_Editor_OnDeleteFeature);
m_Editor.OnStartEditing -= new IEditEvents_OnStartEditingEventHandler(m_Editor_OnStartEditing);
m_Editor.OnStopEditing -= new IEditEvents_OnStopEditingEventHandler(m_Editor_OnStopEditing);
}
public void Startup(ref object initializationData)
{
// InitializationData contains an IEditor reference because of how this class is registered above.
// See http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esriSystem/IExtension_Startup.htm
// Grab the editor reference and setup events to capture
m_Editor = (Editor)initializationData;
m_Editor.OnCreateFeature += new IEditEvents_OnCreateFeatureEventHandler(m_Editor_OnCreateFeature);
m_Editor.OnChangeFeature += new IEditEvents_OnChangeFeatureEventHandler(m_Editor_OnChangeFeature);
m_Editor.OnDeleteFeature += new IEditEvents_OnDeleteFeatureEventHandler(m_Editor_OnDeleteFeature);
m_Editor.OnStartEditing += new IEditEvents_OnStartEditingEventHandler(m_Editor_OnStartEditing);
m_Editor.OnStopEditing += new IEditEvents_OnStopEditingEventHandler(m_Editor_OnStopEditing);
}
#endregion