|
POST
|
I'm trying to add fields to a layer attribute table using pFeatureLayer.FeatureClass.AddField(pFieldEdit) and it takes like two-three minutes per field. I try using layerTable.AddField(pFieldEdit) after converting the layer to an ILayer using ITable layerTable = (ITable)editAttributeLayer and still is very slow. It takes a fraction of a second doing the same operation in the attribute table of the layer directly. Somebody knows why it is to slow doing int using arc objects? or is there a trick to do it fast? I need to add 80+ fields to the layer and even one minute per field would be too long. Any ideas? Thanks in advance. Adding fields is relatively painless and should not be slow. But I'm a little confused on what you are attempting to do... You need to add a field? or 80 of them? From where? How are you assigning the new field parameters to the ITable/Layer? Maybe something is wrong in the looping of the 80 fields? Post some code up.
... View more
05-21-2010
01:06 PM
|
0
|
0
|
578
|
|
POST
|
I have no idea if this would help, or if it's even related to the issue you are having, but have you tried starting/stopping an edit session before/after your calc process?
... View more
05-20-2010
07:00 AM
|
0
|
0
|
320
|
|
POST
|
I have setup FileGDBWorkspaceFactory and define where the geodatabase file path but I how can I get the feature layer from it ?? I'm away from my dev workstation at the moment, but I think it's something like this: Dim pTable As ITable
pTable = pFeatureWorkspace.OpenTable("Feature Class Name Goes here") Or if it's a Layer I think you want something like this: Dim pFeatureLayer As IFeatureClass
pFeatureLayer = pFeatureWorkspace.OpenFeatureClass("Feature Class Name Here")
... View more
05-20-2010
04:51 AM
|
0
|
0
|
1110
|
|
POST
|
Thanks james but can I use it to access data from file geodatabase not from map layers. If the GDB FeatureClass is loaded in ArcMap's TOC, then just set pTable (from the code sample in the other thread) to this. Otherwise, you will have to setup an IFeatureWorkspace and specify the GDB that contains the Tables/FeatureClasses. http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoDatabase/IFeatureWorkspace.htm
... View more
05-20-2010
04:12 AM
|
0
|
0
|
1110
|
|
POST
|
Yes you are right I building ArcGIS windows application and it is a combobox not a dropdownlist. Thanks for your reply This seems to be a popular topic lately 🙂 Here is a recent thread (as of yesterday) where someone is populating a ComboBox Control with the unique values of a particular layer's attribute field: http://forums.arcgis.com/threads/4766-DataStatistics-Interface-and-System.Collection.IEnumerator While this is not necessarily a "DataBinding" solution, it should at least get you started. Good luck!
... View more
05-20-2010
02:52 AM
|
0
|
0
|
1110
|
|
POST
|
Hi, How can I bind attribute field to drop down list in .net application. Thanks alot You will have to be a bit more specific in what you would like to do, as well as the project type (a .NET application can be many different things). Isn't a "DropDownList" is an ASP.NET control (not totally sure on that)? Or are you referring to a ComboBox Control that is placed on a Windows Form or UserControl? I'm not a immediately aware of any specific methods that allow you to bind fields from an attribute table to an ASP.NET DropDownList control, but I'm sure there is a solution to get it done.
... View more
05-20-2010
01:51 AM
|
0
|
0
|
1110
|
|
POST
|
I am away from the office, but you can try this until I return tomorrow: For i = 0 To pData.UniqueValueCount - 1
If Not IsDbBull(CStr(pEnumVar.Current)) Then
strval = CStr(pEnumVar.Current)
MyArray(i) = strval
ReDim Preserve MyArray(i + 1)
value = pEnumVar.MoveNext
End If
Next
... View more
05-19-2010
12:49 PM
|
0
|
0
|
922
|
|
POST
|
Redo the if statement to include an IsDbNull... Instead of: If strval <> " " Then Use: If Not IsDBNull(strval) Then
... View more
05-19-2010
11:37 AM
|
0
|
0
|
922
|
|
POST
|
That did it! Thanks James! Can't believe I was simply missing one crucial line! I'm attempting to convert code from VBA to VB.NET and that's why I ran into this little problem! Thanks again! Glad I could help. Good luck on your conversion project! Take Care
... View more
05-19-2010
09:37 AM
|
0
|
0
|
922
|
|
POST
|
I went ahead and just added the necessary line of code to populate the CboBox Public Sub Sort_Unique(ByVal pLayer As IFeatureLayer, ByVal fieldname As String, ByVal condition As IQueryFilter)
Dim pTable As ITable
Dim pTableSort As ITableSort
Dim sFieldName As String = fieldname
Dim pCursor As ICursor
Dim i As Integer
For i = 0 To pMap.LayerCount - 1
If pMap.Layer(i).Name = "Lots Improved" Then
pLayer = pMap.Layer(i)
' pWellLayer = pLayer
End If
Next
' Gets the attribute table from the passed layer
pTable = pLayer.FeatureClass
' This example sorts the specificed field name
pTableSort = New TableSort
With pTableSort
.Fields = sFieldName
.Ascending(sFieldName) = True
.Table = pTable
End With
' sort the table
pTableSort.Sort(Nothing)
' Loop through sorted records and add to a listbox
pCursor = pTableSort.Rows
Dim pData As IDataStatistics
pData = New DataStatistics
pData.Field = fieldname
pCursor = pLayer.Search(condition, False)
pData.Cursor = pCursor
Dim pEnumVar As System.Collections.IEnumerator
Dim value As Object
pEnumVar = pData.UniqueValues
value = pEnumVar.MoveNext
For i = 0 To pData.UniqueValueCount - 1
cmbLot.Items.Add(CStr(pEnumVar.Current)) '<--- this should add the values to your cmbLot Control
value = pEnumVar.MoveNext
Next
End Sub
... View more
05-19-2010
09:20 AM
|
0
|
0
|
922
|
|
POST
|
To get the unique value string for pEnumVar, setup a String Variable and set it to .Current. Something like: Dim val As String
For i = 0 To pData.UniqueValueCount - 1
value = pEnumVar.MoveNext
val = CStr(pEnumVar.Current) '<--- this will give you the string value of pEnumVar
Next Hi All, The code below retrieves attributes from a shapefile and attempts to put them into a combobox. The majority of the code works fine, but towards the end, where the "value" object is declared is where things go wrong. The pEnumVar should be returning the next value in the row it's looking at, but instead it gets a Boolean value (True or False). It would be great if someone could post some feedback regarding this issue. Thanks for your time, Ruchira Welikala Public Sub Sort_Unique(ByVal pLayer As IFeatureLayer, ByVal fieldname As String, ByVal condition As IQueryFilter)
Dim pTable As ITable
Dim pTableSort As ITableSort
Dim sFieldName As String = fieldname
Dim pCursor As ICursor
Dim i As Integer
For i = 0 To pMap.LayerCount - 1
If pMap.Layer(i).Name = "Lots Improved" Then
pLayer = pMap.Layer(i)
' pWellLayer = pLayer
End If
Next
' Gets the attribute table from the passed layer
pTable = pLayer.FeatureClass
' This example sorts the specificed field name
pTableSort = New TableSort
With pTableSort
.Fields = sFieldName
.Ascending(sFieldName) = True
.Table = pTable
End With
' sort the table
pTableSort.Sort(Nothing)
' Loop through sorted records and add to a listbox
pCursor = pTableSort.Rows
Dim pData As IDataStatistics
pData = New DataStatistics
pData.Field = fieldname
pCursor = pLayer.Search(condition, False)
pData.Cursor = pCursor
Dim pEnumVar As System.Collections.IEnumerator
Dim value As Object
pEnumVar = pData.UniqueValues
value = pEnumVar.MoveNext
For i = 0 To pData.UniqueValueCount - 1
cmbLot.Items.Add(value)
value = pEnumVar.MoveNext
Next
End Sub
... View more
05-19-2010
09:02 AM
|
0
|
0
|
922
|
|
POST
|
Hi James, i don't know how to thank yuo. without your help I would not have ever made. I write the correct code for all who need it. thanks, thanks, thanks Barbara I'm happy to hear you got it working, Barbara!
... View more
05-19-2010
08:26 AM
|
0
|
0
|
1060
|
|
POST
|
James, Just wanted to take a second and say thank you for all the help you gave me on this issue. You were right - while this: pQueryFilter.WhereClause = "MAXWSEL_FT = '" & var & "'" *didn't work this: pQueryFilter.WhereClause = "MAXWSEL_FT = " & var *did, as long as I declared var as the proper type. My employer has had three programmers work on this specific tool over the course of several years. Your help is getting me big brownie points with those who pay my bills, and for that I can only say, "You da man!" Justin Nice. Glad to see you got it working!
... View more
05-18-2010
02:07 PM
|
0
|
0
|
762
|
|
POST
|
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! I simply don't remember how to get the application in VBA. Here are some links, and do a search on ThisDocument: http://forums.esri.com/thread.asp?t=214268&f=987&c=93 http://edndoc.esri.com/arcobjects/8.3/Samples/Editing/Edit%20Tools/Polygon%20Capturing%20Tool/clsPolytrace.htm I honestly can't remember, but something like: 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)
... View more
05-18-2010
01:20 PM
|
0
|
0
|
633
|
|
POST
|
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. First I'd check to make sure you are setting the correct layer. I had added this to the code, expecting you to change the name of the layer to your own: If pGeoFeatureLayer.Name = "The Name of The Layer you Want to Edit Goes Here" Then <--this should changed to your layer Next, I'd make certain that the map reference is correctly set (I think you said you are working in VBA environment, which will have differences from the code I posted). Mainly you need to make sure pEditor is getting set: 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 If not, then you need to correctly set it (I cannot remember how to do it in VBA, something to do with the ThisDocument maybe). Next, I'd step thru the code and see what else is not getting set. If .StartOperation is failing then something has not properly been implemented.
... View more
05-18-2010
12:51 PM
|
0
|
0
|
633
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 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 |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|