simulate a double click to turn on Sketch Edit mode

1198
24
05-18-2010 06:23 AM
DanNguyen
New Contributor
Does anyone know how to simulate a double click in VB to turn on Sketch Edit mode programmatically?

Thanks in advance for your help.
0 Kudos
24 Replies
JamesCrandall
MVP Frequent Contributor
what do you mean by "and wait for user to add feature"?


If you manually start an edit session and have the task set to "Create New Feature", ArcMap will be in a state that is waiting for the user to click in the map display to add new features.
0 Kudos
DanNguyen
New Contributor
Yes, you're right! 🙂  I want to create vertex by adding it to the polyline feature's geometry (Edit Sketch Property table). 
I figure out how to insert it but it only works if I have already double click on the line to select it in ArcMap.  I want codes to double click to select instead.

Where is a good place that you usually search beside ArcGIS Developer page?

Thanks for all the help, James.
0 Kudos
JamesCrandall
MVP Frequent Contributor
Yes, you're right! 🙂  I want to create vertex by adding it to the polyline feature's geometry (Edit Sketch Property table). 
I figure out how to insert it but it only works if I have already double click on the line to select it in ArcMap.  I want codes to double click to select instead.

Where is a good place that you usually search beside ArcGIS Developer page?

Thanks for all the help, James.



Edit: Rather you should search for ITopologicalOperator

http://forums.esri.com/Thread.asp?c=93&f=993&t=103162
0 Kudos
DanNguyen
New Contributor
This code will only select it as a normal select.  I try this already.  It doesn't get me into Edit Sketch mode where I would see all the existing vertices of the polylines.
0 Kudos
JamesCrandall
MVP Frequent Contributor
This code will only select it as a normal select.  I try this already.  It doesn't get me into Edit Sketch mode where I would see all the existing vertices of the polylines.


Try changing the EditTask to Modify instead of Create:

Change this:
pEditTask = GetEditTaskByName(pEditor, "Create New Feature")

To This:
pEditTask = GetEditTaskByName(pEditor, "Modify Feature")
0 Kudos
DanNguyen
New Contributor
Hi James,

I think here is the sequence of what needed to happen for my code:

1.  Select the line feature  - I got this
2.  Retrieve the selected feature's geometry  and pass it to EditSketch - not yet
3.  Add/Insert my X,Y Coordinates into its geometry - know how to do

So, I guess I need to work on the codes for step 2.  Do you happen to have this code?

Thanks!
0 Kudos
JamesCrandall
MVP Frequent Contributor
Hi James,

I think here is the sequence of what needed to happen for my code:

1.  Select the line feature  - I got this
2.  Retrieve the selected feature's geometry  and pass it to EditSketch - not yet
3.  Add/Insert my X,Y Coordinates into its geometry - know how to do

So, I guess I need to work on the codes for step 2.  Do you happen to have this code?

Thanks!


Did you make the change I suggested?  Instead of the "Create new feature" task, change this to "Modify Feature".  This would do as you wanted: show the verticies of the selected features.  So, wherever you are invoking the Start Editing method in your application is where you'd specify the task type...  In my example, I am invoking this process in the click event of a button control that I've added:


Private Sub btnDrawTarget_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDrawTarget.Click
           Dim pEditTask As ESRI.ArcGIS.Editor.IEditTask
            GetEditorReference()
            startEditing(pEditor)
            If m_flag2 = True Then
                SetEvents()
                pEditTask = GetEditTaskByName(pEditor, "Modify Feature") '<-------change this From "Create New Features"
                pEditor.CurrentTask = pEditTask
            End If
End Sub



I really have no idea what exactly is "passing geometery to the edit sketch".
0 Kudos
DanNguyen
New Contributor
I am going to try .... I'll let you know.  Thanks!
0 Kudos
DanNguyen
New Contributor
Hi James,

I tried to compile to code.  There is an error saying 'GetEditTaskByName' not defined.  Any idea?
0 Kudos
JamesCrandall
MVP Frequent Contributor
Hi James,

I tried to compile to code.  There is an error saying 'GetEditTaskByName' not defined.  Any idea?



Sorry, I did not inlclude that.  Just add this to your class/app:

Public Function GetEditTaskByName(ByRef pEditor As ESRI.ArcGIS.Editor.IEditor, ByRef strEditTaskName As String) As ESRI.ArcGIS.Editor.IEditTask
        Dim i As Integer
        For i = 0 To pEditor.TaskCount - 1
            If UCase(pEditor.Task(i).Name) = UCase(strEditTaskName) Then
                GetEditTaskByName = pEditor.Task(i)
                Exit For
            End If
        Next i

    End Function
0 Kudos