yes, something is not set correctly. I was stepping through the codes and that is where it stops. I had this piece of code and it works this morning. Anyway, I'll let you know.Thanks!
Dim pMXDoc As IMxDocument Dim pMap As IMap Dim pID As New UID ' QI for IMXDocument Set pMXDoc = ThisDocument 'QI for the Editor pID.Value = "esriCore.Editor" Set pEditor = Application.FindExtensionByCLSID(pID)
Hi James,I keep getting a run time error @ 'pEditor.StartOperation' in startEditing routine and I am not sure why. Any idea?I'm still trying to figure it out.Dan.
If pGeoFeatureLayer.Name = "The Name of The Layer you Want to Edit Goes Here" Then <--this should changed to your layer
Private Sub GetEditorReference() Dim pID As ESRI.ArcGIS.esriSystem.UID pID = New ESRI.ArcGIS.esriSystem.UID pID.Value = "esriCore.Editor" pEditor = m_pApp.FindExtensionByCLSID(pID) End Sub
Hi James,I tried to compile to code. There is an error saying 'GetEditTaskByName' not defined. Any idea?
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
Hi James,I think here is the sequence of what needed to happen for my code:1. Select the line feature - I got this2. Retrieve the selected feature's geometry and pass it to EditSketch - not yet3. Add/Insert my X,Y Coordinates into its geometry - know how to doSo, I guess I need to work on the codes for step 2. Do you happen to have this code?Thanks!
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
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.
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.
what do you mean by "and wait for user to add feature"?
I want the codes to go through the polyline layer and for each polyline, insert a vertex at its corresponding X,Y in the point layer.
Hi James,That is OK if you can't help anymore.Just so you know ... I have a layer of polylines and for each of these polyline, I want to insert a vertex on it (besides its existing vertices) at a known X,Y coordinates. I got most everything figured out except how to turn on its Edit Sketch Properties. Manually, when you double click on a polyline you would see all its vertices. And I want to do this via the codes.I know VB 6, VB.Net and C also. So if you have the codes in these languages, that will work too.Thanks, James.
Hi James,Thanks for replying.I got the code to turn on the Editor and select the line segment I want but Edit Sketch doesn't know its geometry. For Edit Sketch to know about its geometry I have to double clik on the line segment manually and I want to program the double click because I have a list of line segments that I want to go through and edit.Thanks!
Does anyone know how to simulate a double click in VB to turn on Sketch Edit mode programmatically?Thanks in advance for your help.
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, "Create New Feature") pEditor.CurrentTask = pEditTask End If End Sub Private Sub GetEditorReference() Dim pID As ESRI.ArcGIS.esriSystem.UID pID = New ESRI.ArcGIS.esriSystem.UID pID.Value = "esriCore.Editor" pEditor = m_pApp.FindExtensionByCLSID(pID) End Sub Private Sub SetEvents() 'set the current tool to be the editor Sketch tool Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem Dim pUID As New ESRI.ArcGIS.esriSystem.UID pUID.value = "esriCore.SketchTool" pCommandItem = m_pApp.Document.CommandBars.Find(pUID) m_pApp.CurrentTool = pCommandItem m_pEditEvents = pEditor End Sub Private Sub startEditing(ByRef pEditor As ESRI.ArcGIS.Editor.IEditor) Try Dim pMxDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument Dim pMap As ESRI.ArcGIS.Carto.IMap Dim pfeaturelayer As ESRI.ArcGIS.Carto.IFeatureLayer Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset Dim pEditLayers As ESRI.ArcGIS.Editor.IEditLayers Dim msg As Object pMxDoc = m_pApp.Document pMap = pMxDoc.FocusMap pEditLayers = pEditor 'Check to see if proper dataset is loaded before editing, if so, then edit Dim i, idx As Integer Dim pGeoFeatureLayer As ESRI.ArcGIS.Carto.IGeoFeatureLayer m_flag2 = False For i = 0 To pMxDoc.FocusMap.LayerCount - 1 If (TypeOf pMxDoc.FocusMap.Layer(i) Is ESRI.ArcGIS.Carto.IGeoFeatureLayer) Then pGeoFeatureLayer = pMxDoc.FocusMap.Layer(i) If pGeoFeatureLayer.Name = "The Name of The Layer you Want to Edit Goes Here" Then m_flag2 = True idx = i Exit For End If End If Next i If m_flag2 = True Then pfeaturelayer = pMap.Layer(idx) pDataset = pfeaturelayer.FeatureClass pEditor.StartEditing(pDataset.Workspace) pEditor.StartOperation() pEditLayers.SetCurrentLayer(pfeaturelayer, 0) End If Catch ex As Exception MsgBox(ex.ToString) Exit Sub End Try End Sub
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.