Problem - trying to 'Find' an Editor Extension

2270
15
Jump to solution
06-20-2012 12:36 PM
Highlighted
by Anonymous User
Not applicable
Original User: robit2

Hi,

I am new to the vb.net and ArcGIS development environment.  
I am trying to add some custom code to our ArcGIS application, through vb.net. 

There was an existing vb project that existed, for various custom code functionality, that was written previously by other people no longer in this group.

They had an IExtension interface.  I have just found it to be an Editor Extension class.

I have created a new IToolControl class, that implements a new drop-down ComboBox.  I have used the Tools->Customize->Commands tab, to add(drag) this new ToolControl to a custom toolbar.    This ComboBox is databound to an existing Oracle Table.  This process works.

I now need to use the selected value of the new combobox, and assign it to a different variable in the existing Editor Extension Class.

I am using the following code in my new IToolControl class.
However, the "m_pExt" value is always Null or Nothing.  

Am I missing something ?

Thanks so much.


  Public Sub OnCreate(ByVal hook As Object) Implements ESRI.ArcGIS.SystemUI.ICommand.OnCreate
      
        m_pApp = CType(hook, IApplication)

        m_pMxDoc = m_pApp.Document
     
  
      
        Dim u As UID = New UIDClass

        u.Value = "SaskTelVBNet.sln.Extension"

         m_pExt = m_pApp.FindExtensionByCLSID(u)

        m_AC_ComboBoxForm = New FrmControls

 
        m_AC_ComboBoxForm.ACCOUNT_CODE_TYPETableAdapter.Fill(m_AC_ComboBoxForm.DataSet7.ACCOUNT_CODE_TYPE)
    
      
    End Sub
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Occasional Contributor
Please try the following for the editor extension reference:

            
            UID uid = new UIDClass();
            uid.Value = "esriEditor.Editor";
            IExtension Extension = ArcMap.Application.FindExtensionByCLSID(uid);
            IEditor m_editor = Extension as IEditor;

            IExtension Editor_Extension;
            UID attributeuID = new UIDClass();
            attributeuID.Value = "esriEditor.AttrWindow";
            Editor_Extension = m_editor.FindExtension(attributeuID) as IExtension;

View solution in original post

Reply
0 Kudos
15 Replies
Highlighted
Occasional Contributor
Have you checked the class id for your editor extension? Does the string you use for the u.Value have the right value. You can use either the extension name or the UID string for the u.Value. For example:

            UID uid = new UIDClass();
            // uid.Value = "{F8842F20-BB23-11D0-802B-0000F8037368}";
            uid.Value = "esriEditor.Editor";
            IExtension Extension = m_application.FindExtensionByCLSID(uid);

BTW, you can find the these two values in the Component Category Manager (see attached image).
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: agray1

Have you tried passing in the GUID the value property of the uid object instead of the name of the extension?  I always find the GUID easier to deal with.  The guid is the classid of the class, you need to put it between {} brackets.
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: robit2

Have you checked the class id for your editor extension? Does the string you use for the u.Value have the right value. You can use either the extension name or the UID string for the u.Value. For example:

            UID uid = new UIDClass();
            // uid.Value = "{F8842F20-BB23-11D0-802B-0000F8037368}";
            uid.Value = "esriEditor.Editor";
            IExtension Extension = m_application.FindExtensionByCLSID(uid);

BTW, you can find the these two values in the Component Category Manager (see attached image).



Thanks for the response.

The Editor Extension I'm trying to 'find' is a custom extension created previously.
I have double-checked the ProgId value.  
When tracing, I believe the u.value gets the ClassID value, and it appears correct, yes.

(I think the problem is that it is an Editor Extension rather than an Application Extension maybe ? 
I just created a quick test Application Extension class, and when I use the same code, with this ProdId value for this new Application Extension Class, it finds it correctly.  
Can I not 'find' a custom Editor Extension from the existing map maybe ?


Here is part of this custom extension :



Imports Microsoft.VisualBasic
Imports System
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Editor
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.ADF.CATIDs

''' <summary>
''' Allow the associated property sheet to turn validation on and off.
''' </summary>

<ComClass(SaskTelExtension.ClassId, SaskTelExtension.InterfaceId, SaskTelExtension.EventsId), _
ProgId("SaskTelVBNet.sln.Extension")> _
Public Class SaskTelExtension : Implements IExtension
#Region "COM Registration Function(s)"
    <ComRegisterFunction(), ComVisibleAttribute(False)> _
    Public Shared Sub RegisterFunction(ByVal registerType As Type)
        ' Required for ArcGIS Component Category Registrar support
        ArcGISCategoryRegistration(registerType)

        'Add any COM registration code after the ArcGISCategoryRegistration() call

    End Sub

    <ComUnregisterFunction(), ComVisibleAttribute(False)> _
    Public Shared Sub UnregisterFunction(ByVal registerType As Type)
        ' Required for ArcGIS Component Category Registrar support
        ArcGISCategoryUnregistration(registerType)

        'Add any COM unregistration code after the ArcGISCategoryUnregistration() call

    End Sub

#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 Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
        Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
        EditorExtensions.Register(regKey)

    End Sub
    ''' <summary>
    ''' Required method for ArcGIS Component Category unregistration -
    ''' Do not modify the contents of this method with the code editor.
    ''' </summary>
    Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
        Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
        EditorExtensions.Unregister(regKey)

    End Sub

#End Region
#End Region


#Region "COM GUIDs"
    ' These  GUIDs provide the COM identity for this class
    ' and its COM interfaces. If you change them, existing
    ' clients will no longer be able to access the class.
    Public Const ClassId As String = "09836d20-254d-4564-ac99-4a91602abeae"
    Public Const InterfaceId As String = "45dd6c0b-f4a9-4145-9b12-befada5b5eaa"
    Public Const EventsId As String = "3d7ef4d3-f0c3-465c-a2e1-f0b8c636ca4f"
#End Region
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: robit2

Have you tried passing in the GUID the value property of the uid object instead of the name of the extension?  I always find the GUID easier to deal with.  The guid is the classid of the class, you need to put it between {} brackets.


Hi,
Thanks for your response.


I tried that now, and it didn't seem to make a difference.

Maybe I have to 'find' and Editor Extension by calling the FindExtensionByCLSID from the IEditor Object, rather than the IApplication object ?


Public Sub OnCreate(ByVal hook As Object) Implements ESRI.ArcGIS.SystemUI.ICommand.OnCreate
       m_pApp = CType(hook, IApplication)

         
       

        Dim u As UID = New UID

        u.Value = "{09836d20-254d-4564-ac99-4a91602abeae}"


       
        m_pExt = m_pApp.FindExtensionByCLSID(u)
Reply
0 Kudos
Highlighted
Regular Contributor II
If memory serves me, editor extensions are the same as regular extensions but they are registered in a different category.  They are loaded only after the edit session is started.  They stick around after the edit session is stopped.  Do you have an edit session started when you run your code?
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: feng.zhang.esri

Thanks for the response.

The Editor Extension I'm trying to 'find' is a custom extension created previously.
I have double-checked the ProgId value.  
When tracing, I believe the u.value gets the ClassID value, and it appears correct, yes.

#End Region


The application object should be good to use. I would suggest tying the followings:

1. Try to find build-in extensions, such as "esriEditor.AttrWindow" ...
2. Make sure the extension appears on the Category Manager;
3. Make sure the extension is loaded and enabled.
Reply
0 Kudos
Highlighted
Regular Contributor II
D'Oh, I just re-read your original post.  You shouldn't put the call to find extension in an ICommand OnCreate event.  If you place the command on a toolbar in ArcMap and the tool bar is visible and turn on when you start ArcMap, the OnCreate is triggered during the ArcMap start up before extensions are created.
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: robit2

I tried finding a built-in Editor extension ....... "esriEditor.AttrWindow" .
No luck.  But I suspect this was because not in an Edit Session ?

I have put some breakpoints in code ...and when tracing along, it runs the Startup method of our custom Editor Extension ... before the initial ArcMap "Open dialog box" even comes up.   Then when I select a Template to open up on, my OnCreate method of my custom tool runs.  So I figured it shoudl have access to our custom extension ?

But I'm wondering,  if it still has be in an Editing session, to access this custom Editor Extension ?
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: robit2

However, as a test, I created a quick "Application" Extension class, with stubbed out code.

In the same part of code (in my OnCreate method of my new ToolControl class), I tried to "Find" this new custom Application Class, with the same code I have, just with the different ProgId, and traced through ... it found it no problem.
Reply
0 Kudos