|
POST
|
OK well if this was me I would try to start to narrow down what is causing the problem? Try just writing the shape, if code runs then it suggests its to do with the transferring of the remaining attributes. Then try the reverse and if that is inconclusive try just writing blank rows?
... View more
10-08-2013
06:47 AM
|
0
|
0
|
2875
|
|
POST
|
Brendan, I don't think the Object model exposes any sort of hook into that dialog. Happy for someone else to prove me wrong? Duncan
... View more
10-08-2013
06:43 AM
|
0
|
0
|
862
|
|
POST
|
The error hints at a server, are you storing data in ArcServer? If so it might be some weird permissions problem, if it is then I have to defer to someone else with more knowledge of ArcServer (as I have not used it). So that in mind can you try putting your newFc in a file geodatabase and try writing to that?
... View more
10-07-2013
11:22 AM
|
0
|
0
|
2875
|
|
POST
|
Without seeing the actual error message and as the code looks OK to me I'm guessing the problem is to do with your newFC. Are you trying to: Insert incorrect geometries (e.g. storing a polyline in a point FeatureClass)? Does the source featureclass have a different spatial reference? Does the source featureclass support MZ values and your newFC does not? Also can you confirm your queryfilter is actually selecting data?
... View more
10-07-2013
10:44 AM
|
0
|
0
|
2875
|
|
POST
|
Richard, You get the tick as you got me "bumbling" around the part of ArcObjects I needed to be looking at. If anyone from ESRI is reading this then you really need to add some guidance to the Help about what exactly is "UserData" on the IDockableWindow Interface. There is no indication of what this returns, a simple example of the types of objects returned would help us developers. So... after several hours of banging my head against a brick wall I finally worked out what exactly is returned by "UserData". I was then able to hook into the catalog and refresh the docked window. I supply my VBA code below in the hope that this will save other developers from going crazy but ideally the Help page should be updated with some trivial scenarios to allow the developer to understand what Userdata is. Public Sub test()
Dim pDockableWindowManager As IDockableWindowManager
Set pDockableWindowManager = Application
Dim sUID As UID
Set sUID = New UID
sUID.Value = "{7F09BEFF-4F85-48A2-A3DC-39430262799E}" 'GxBrowserDockWindow
Dim pDockableWindow As IDockableWindow
Set pDockableWindow = pDockableWindowManager.GetDockableWindow(sUID)
If pDockableWindow.IsVisible Then
' Get Browser
Dim pGXBrowser As IGxBrowser
Set pGXBrowser = pDockableWindow.UserData
' Get the Catalog
Dim pGXCatalog As IGxCatalog
Set pGXCatalog = pGXBrowser.InternalCatalog
' QI Catalog into GXObject
Dim pGXObject As IGxObject
Set pGXObject = pGXCatalog
' QI GxObject into GxObjectContainer
Dim pGxObjectContainer As IGxObjectContainer
Set pGxObjectContainer = pGXObject
' Get Gxobjects as an enumerate
Dim pEnumGxObject As IEnumGxObject
Set pEnumGxObject = pGxObjectContainer.Children
' Cycle through objects until we find the Folder Connections, then break out of loop
Dim pGxObject2 As IGxObject
Set pGxObject2 = pEnumGxObject.Next
Do While Not pGxObject2 Is Nothing
If TypeOf pGxObject2 Is IGxFolderConnections Then
Exit Do
End If
Set pGxObject2 = pEnumGxObject.Next
Loop
' Re-point GxObjectContainer to folder connection GxObject and refresh all children GxObjects
Set pGxObjectContainer = pGxObject2
Set pEnumGxObject = pGxObjectContainer.Children
Set pGxObject2 = pEnumGxObject.Next
Do While Not pGxObject2 Is Nothing
pGxObject2.Refresh
Set pGxObject2 = pEnumGxObject.Next
Loop
End If
End Sub
... View more
10-07-2013
03:48 AM
|
0
|
0
|
3032
|
|
POST
|
Richard, Many thanks for your help but I think we are talking about different things? I'm talking about this window: [ATTACH=CONFIG]28077[/ATTACH] If run the following code: Public Sub test()
Dim pMXDoc As IMxDocument
Set pMXDoc = ThisDocument
Dim n As Integer
n = pMXDoc.ContentsViewCount
Dim pContentsView As IContentsView
For i = 0 To n - 1
Set pContentsView = pMXDoc.ContentsView(i)
Debug.Print pContentsView.Name
Next i
End Sub
It displays only the following names (so no catalog window): Display Source Visible Selection
... View more
10-06-2013
11:18 AM
|
0
|
0
|
3032
|
|
POST
|
All, I'm stumpted on how one refreshes the Catalog window in ArcMap and I have been unsuccessful in finding any advice or examples in the ArcObjects API help. I am using 10.2 and currently trying to put this simple bit of code together in VBA but ultimately I intend do it in VB .net. I am developing a tool that at some point blitzes a folder but I notice if the catalog window is open and docked in ArcMap this does not automatically get refreshed. So I'm simply trying to refresh the catalog tree in the catalog window which would hopefully show that a folder had been deleted. Currently my VBA test code is: Public Sub test() Dim pDockableWindowManager As IDockableWindowManager Set pDockableWindowManager = Application Dim sUID As UID Set sUID = New UID sUID.Value = "{7F09BEFF-4F85-48A2-A3DC-39430262799E}" 'GxBrowserDockWindow Dim pDockableWindow As IDockableWindow Set pDockableWindow = pDockableWindowManager.GetDockableWindow(sUID) Debug.Print pDockableWindow.Caption ' This returns "Catalog" so I know I have a handle on it If pDockableWindow.IsVisible Then ' ??? How to refresh it it? End If End Sub
... View more
10-06-2013
09:58 AM
|
0
|
6
|
4216
|
|
POST
|
Rick, If am image has been geo-referenced then it should return an extent. You could have a scenario where an image has a world file but no projection information but it would return an extent. So knowing that, the VBA code below demonstrates how to test for this. I leave it up to you to wrap it up into a loop. The limitation with this example is that it is assumed that the raster is not in a geographical coordinate system. Public Sub Test() ' This code expects the first layer in the TOC to be a raster ' Get map Dim pMXD As IMxDocument Set pMXD = ThisDocument Dim pMap As IMap Set pMap = pMXD.FocusMap ' Get raster Dim pLayer As ILayer Set pLayer = pMap.Layer(0) Dim pRasterLayer As IRasterLayer Set pRasterLayer = pLayer ' Get extent Dim pGeoDataset As IGeoDataset Set pGeoDataset = pRasterLayer Dim pEnv As IEnvelope Set pEnv = pGeoDataset.Extent ' Test minimum value, assumes rasters are not in decimal degrees If pEnv.XMin = -0.5 Then Debug.Print "This raster has no extent so can't be geo-referenced!" Else Debug.Print "This raster is geo-referenced!" End If End Sub
... View more
10-04-2013
02:21 PM
|
0
|
0
|
4064
|
|
POST
|
Chris, Before you increased the number of points in your test data it's interesting to note that your run times are around 9 to 10 seconds. Mine were around the 20 second mark! I'm guessing this is down to you having a superior PC? The PC that I did the testing on was a 32 bit operating system with a Intel Core 2 CPU (2.4Ghz). I was wondering after I posted if the performance benefit would be noticeable in a much more complex scenario? For example some cursor going through some dataset farming out selections for subsequent processing steps. I also wonder if this make FeatureLayer "micro" boost in performance extends to TableViews and RasterLayers? Anyway it's good to have a naysayer casting doubt at every opportunity as I would never have queried such a technique. Duncan
... View more
10-04-2013
10:50 AM
|
0
|
0
|
991
|
|
POST
|
All, In a recent thread discussed here it was suggested that creating a FeatureLayer from a FeatureClass can improve the performance of arcpy. It was clear from the subsequent discussions that this was not necessarily accepted by others and I was skeptical as I have never seen any reference to this "top tip". So with time to kill I set out to test this and I am reporting my findings for others to mull over. I have 10.2 on a VISTA OS and a I ran everything in Pyscripter. On each run I reset the python interpreter window and reset the source dataset so the conditions were the same. I had stopped all other applications and did not touch the keyboard whilst the code ran. I had created a point shapefile with 1000 random points, my test code simply added a field and then calculated a constant value into this new field. The code repeated these steps 49 times. I record the start and end times so I could work out how long it took. I repeated the test 10 times for each scenario. My null hypothesis is that there is no performance difference. The two test scenarios where: Access the source dataset as a full path name, what you typically see in many examples in the ESRI help Create a FeatureLayer first and use that instead of the full path name My code for accessing the full path was: import arcpy
import time
print "START TIME = " + time.asctime()
# Source dataset to update
fc = r"C:\Scratch\TestLayer.shp"
# Create a list of numbers from 1 to 50
l = range(1,50,1)
for i in l:
# Create a field name and add it to dataset
name = "F_" + str(i)
print "Processing " + name
arcpy.AddField_management(fc,name,"LONG")
# Populate field with a constant 999
arcpy.CalculateField_management(fc,name,"999","VB")
print "END TIME = " + time.asctime()
My code for accessing a FeatureLayer was: import arcpy
import time
print "START TIME = " + time.asctime()
# Source dataset to update
fc = r"C:\Scratch\TestLayer.shp"
fl = "TestLayer"
arcpy.MakeFeatureLayer_management(fc,fl)
# Create a list of numbers from 1 to 50
l = range(1,50,1)
for i in l:
# Create a field name and add it to dataset
name = "F_" + str(i)
print "Processing " + name
arcpy.AddField_management(fl,name,"LONG")
# Populate field with a constant 999
arcpy.CalculateField_management(fl,name,"999","VB")
print "END TIME = " + time.asctime()
For the 10 test runs the mean time for running the code for: full path name was 22 seconds FeatureLayer was 19.5 seconds I did a Two-Sample T-Test in Minitab which is significant which means I reject my null hypothesis. Two-sample T for fl vs fc N Mean StDev SE Mean fl 10 19.500 0.527 0.17 fc 10 22.000 0.816 0.26 Difference = mu (fl) - mu (fc) Estimate for difference: -2.500 95% CI for difference: (-3.155, -1.845) T-Test of difference = 0 (vs not =): T-Value = -8.13 P-Value = 0.000 DF = 15 So for this simple scenario there was a significant difference in performance by creating a FeatureLayer first... Interesting hey?
... View more
10-04-2013
06:18 AM
|
0
|
3
|
1144
|
|
POST
|
Curtis, Your #2 point sounds really interesting. So you are saying that by explicitly creating a FeatureLayer from a featureclass path (e.g. c:\temp\houses.shp) you can get a performance boost if that FeatureLayer is used multiple times within the Python script? Why is this not mentioned in the Help? If it is I've never spotted it! This sounds like this should be adopted as best practice? Duncan
... View more
09-26-2013
06:11 AM
|
0
|
0
|
2107
|
|
POST
|
Sameer, Whilst I agree that the help for this Class is missing basic examples on how to implement the tool and is something that ESRI should rectify, a simple search on this forum for "RasterCalculator" will find you enough code examples to work out how to use it.
... View more
09-26-2013
05:52 AM
|
0
|
0
|
1243
|
|
POST
|
So in ArcMap when you use the AddIn manager, you can remove the folder and\or delete Addin? If you do that then restart ArcMap are you saying they are still showing up in the AddIn manager? Also where are you compiling your addin too? You can see this in visual studio in the build output path in project properties > compile. If you have not set this then it will default to some location and I'm wondering each time you compile\debug it you are resetting ArcMap to point to it.
... View more
09-25-2013
02:39 PM
|
0
|
0
|
849
|
|
POST
|
Steve, AddIns get cached. I have Windows VISTA and the location for my machine is here: C:\Users\xxx\AppData\Local\ESRI\Desktop10.1\AssemblyCache Before you try blitzing that (but only after you made a backup!) try using the AddIn manager in Arcmap to remove the AddIn. Duncan
... View more
09-25-2013
09:03 AM
|
0
|
0
|
849
|
|
POST
|
All, Odd problem here and I have not found a solution to it. I'm using ArcGIS 10.1, VB .net and the source data is a shapefile.At some point in my tool I add a field using the IFeatureClass.AddField method and populate it with values but when I add this field it drops the spatial index on the dataset. In ArcMap if I open the Attribute table I see the * in the Shape field which suggests its still there but I know its not. Later on in my tool I test if a dataset has a spatial index, if not I add one. I test if the dataset has a spatial index with the following code:
Dim pFeatureClass As IFeatureClass
pFeatureClass = m_pFeatureLayer_River.FeatureClass
Dim pIndexes As IIndexes
Dim pEnumIndex As IEnumIndex
pIndexes = pFeatureClass.Indexes
pEnumIndex = pIndexes.FindIndexesByFieldName(pFeatureClass.ShapeFieldName)
Dim pIndex As IIndex
pIndex = pEnumIndex.Next
If pIndex Is Nothing Then
' Add Spatial Index
End If
This always fails suggesting the spatial index exists but I know it does not as another tool runs very slowly without it.Only when I restart ArcMap, load the shapefile, open attribute table do I see that the * in the shape field has disappeared.So my question is knowing that I use the IFeatureClass.AddField method to add a field how do I "refresh" ArcMap to pick up on the fact that the spatial index has been lost and allow my check for spatial index code to work? Duncan
... View more
09-25-2013
08:33 AM
|
0
|
0
|
987
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-03-2026 07:31 AM | |
| 3 | 06-29-2026 05:17 AM | |
| 1 | 02-15-2023 05:45 AM | |
| 1 | 06-16-2026 02:37 AM | |
| 1 | 06-15-2026 08:29 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|