POST
|
Barbara, You could try getting the SelectedText or SelectedValue of the Combobox instead of trying to get .Text... Something like this (I can't remember the exact statment to use and will have to test tomorrow): If Not cboStrada.SelectedText = "" Then ' Or try cboStrada.SelectedValue
strQuery = "Nome_Strada = '" & cboStrada.Text & "'"
ElseIf Not cboCodice.SelectedText = "" Then
strQuery = "Codice = '" & cboCodice.Text & "'"
ElseIf Not cboProvincia.SelectedText = "" Then
strQuery = "Provincia = '" & cboProvincia.Text & "'"
Else
MsgBox ("No values set in any of the ComboBoxes!")
End If
... View more
05-18-2010
12:27 PM
|
0
|
0
|
581
|
POST
|
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
... View more
05-18-2010
10:49 AM
|
0
|
0
|
594
|
POST
|
hello, I better explain what it will do. Attached are two photos that you show what can I do now. I would however be able to do a search that lets you select any value of any combobox and not just one. I would add these other queries: strQuery = "Nome_Strada= '" & cboStrada.Text & "' and Codice = '" & cboCodice.Text & "'and Provincia = '" & cboProvincia.Text & "'" or strQuery = "Nome_Strada= '" & cboStrada.Text & "' or Codice = '" & cboCodice.Text & "'and Provincia = '" & cboProvincia.Text & "'" I tried with if then else cycles but the result is always and only, the first choice in the cycle if. Sorry if I was not too clear. Thanks. I think you mean you'd like If/ElseIf statements based upon the values in the ComboBoxes? Maybe something like: If Not cboStrada.Text = "" Then
strQuery = "Nome_Strada = '" & cboStrada.Text & "'"
ElseIf Not cboCodice.Text = "" Then
strQuery = "Codice = '" & cboCodice.Text & "'"
ElseIf Not cboProvincia.Text = "" Then
strQuery = "Provincia = '" & cboProvincia.Text & "'"
Else
msgBox("No values set in any of the ComboBoxes!")
End If
... View more
05-18-2010
10:01 AM
|
0
|
0
|
581
|
POST
|
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".
... View more
05-18-2010
09:54 AM
|
0
|
0
|
594
|
POST
|
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")
... View more
05-18-2010
09:03 AM
|
0
|
0
|
594
|
POST
|
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
... View more
05-18-2010
08:49 AM
|
0
|
0
|
594
|
POST
|
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.
... View more
05-18-2010
08:19 AM
|
0
|
0
|
594
|
POST
|
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. Now we are getting pretty far away from what you orignially posted what you wanted --- I thought you wanted to invoke an edit session and allow the user to add features via "Create New Features". That's what the code I posted does. ...Now it seems that you'd like to generate verticies at the intersection points of the polyline layer, which is pretty different than what I thought you needed per your first post. I don't have any examples of what you want and would have to hunt around for something. Do a search for creating verticies at intersections.
... View more
05-18-2010
08:17 AM
|
0
|
0
|
764
|
POST
|
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. But Dan, the code I posted above will do that. It starts an edit session, sets the target layer, and waits for the user to add features.
... View more
05-18-2010
07:43 AM
|
0
|
0
|
764
|
POST
|
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! Hmm.. I'm not exactly sure what you are trying to accomplish. Also, you are not going to be able to alter how the existing built in tools of ArcMap actually behave because it's compiled. Your best bet might be in setting up an Event listener to a double-click event that occurs in the ActiveView maybe? Not sure --- my VBA is all tucked away and rarely do I even access it because the .mxd's take so long to open (because they have layers from old SDE db's! 😄 ) Sorry I couldn't be of more help.
... View more
05-18-2010
07:30 AM
|
0
|
0
|
764
|
POST
|
dan, What programming environment are you working in? VBA, VB6, VB.NET?
... View more
05-18-2010
06:57 AM
|
0
|
0
|
764
|
POST
|
Does anyone know how to simulate a double click in VB to turn on Sketch Edit mode programmatically? Thanks in advance for your help. Not real sure where you'd get the double-click event at, but in order to invoke the Edit Sketch you will have to start an edit session and specify the target layer you want to create/modify... VB.NET: 'This ex shows a button on a ToolBar I've created 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
... View more
05-18-2010
06:43 AM
|
0
|
0
|
764
|
POST
|
More discoveries. The GIS team figured out that in some of their shapefiles, the data type had been switched from Double to Float, which apparently causes trouble when trying to query the attribute table. They're in the process of fixing that up. In the meantime, I switched to querying a different field, and am thrilled and horrified by what I have found. First the good news. If I hard code the field's value, things work perfectly! For example: pQueryFilter.WhereClause = "MAXWSEL_FT = 6322.9" returns the correct value and places it right where I want it in the table. Bravo! Now the bad news... As we all know, it does no good to have a hard coded value. I need a variable that can hold a value based on user input. First I tried to use the value directly from the combo box: pQueryFilter.WhereClause = "MAXWSEL_FT = '" & cbTransect1.EditText & "'" No luck. (FYI, cbTransect1.EditText's Type is String, which I didn't know until this afternoon) So I tried creating a different variable and converting cbTransect1.EditText to String, which I now know was redundant: Dim strRegion as String strRegion = CStr(cbTransect1.EditText) pQueryFilter.WhereClause = "MAXWSEL_FT = '" & strRegion & "'" Still no luck. Then I got the bright idea of storing the static value (the one that had worked earlier) in the strRegion variable. Would you believe that it didn't work either? Dim strRegion as String strRegion = "6322.9" pQueryFilter.WhereClause = "MAXWSEL_FT = '" & strRegion & "'" It seems like it just doesn't like anything when its passed in through a variable. I've seen loads of examples with this same syntax. Can anyone spot what's wrong with my SQL? I think it just might all boil down to a strings-as-numbers type problem. For example, if this works: pQueryFilter.WhereClause = "MAXWSEL_FT = 6322.9" ....then I think you should setup your QueryFilter as such (not tested, and going from memory, maybe someone can chime in until tomorrow when I get in front of some of my ArcObjects): Dim var as Decimal var = CDec(cbTransect1.EditText) pQueryFilter.WhereClause = "MAXWSEL_FT = " & var
... View more
05-17-2010
01:46 PM
|
0
|
0
|
440
|
POST
|
Double check your WhereClause and make certain that chTransect1.EditText is correct and actually an attribute in the row: pQueryFilter.WhereClause = "DS_DIST_MI = '" & cbTransect1.EditText & "'" You might even setup a variable instead of directly adding the control's value into the query string. This way you could check it before setting the whereclause. (also: I see you are working in VB6, which I don't have and not working with, so this may not work for you. I don't recall if there is a SelectedValue.ToString for a ComboBox control in VB6!). Get the text of the SelectedValue or SelectedText in the Combobox: Dim cbText as String
cbText = CStr(Me.cboRateClass.SelectedValue.ToString)
'or try
cbText = CStr(Me.cboRateClass.SelectedText.ToString)
'use this variable in your WhereClause
pQueryFilter.WhereClause = "DS_DIST_MI = '" & cbText & "'"
... View more
05-17-2010
09:38 AM
|
0
|
0
|
440
|
POST
|
James, Kirk, Thanks for your detailed replies. Both of them helped a great deal - in fact, I think James completed my *next* project for me! Just think how pleased my boss will be. I'm afraid I wasn't as detailed or descriptive as I needed to be in this post. I'm going to start a new one today, and if either of you would like, I'd love to hear from you. Thanks again for your help. Justin No problem -- you can start a new thread or post up a modification on this one. Someone will help you come up with a solution I'm sure. Please let me know if the ADO.NET DataTable approach works -- I've used this in several apps with a great deal of success and have realized other benefits like portability into other N-Tier architectures. So, it's a good one to keep in mind IMO. 😉
... View more
05-17-2010
09:21 AM
|
0
|
0
|
474
|
Title | Kudos | Posted |
---|---|---|
1 | 10-25-2022 11:46 AM | |
1 | 08-08-2022 01:40 PM | |
1 | 02-15-2019 08:21 AM | |
2 | 08-14-2023 07:14 AM | |
1 | 07-10-2023 01:25 PM |
Online Status |
Offline
|
Date Last Visited |
08-19-2024
09:15 PM
|