|
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
|
2975
|
|
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
|
4159
|
|
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
|
4030
|
|
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
|
973
|
|
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
|
1126
|
|
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
|
2078
|
|
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
|
1218
|
|
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
|
839
|
|
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
|
839
|
|
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
|
979
|
|
POST
|
I have to admit I have never utilised any snapping objects in ArcObjects so maybe an interface does exist? If not, are you saying the geometry you are snapping to has a Z value? If so, this is one way to do it: Cast your geometry into IPointCollection, cycle over this until you have the vertex you snapped to then query that vertex for a Z value. The method I am suggesting assumes you are snapping to vertices.
... View more
09-18-2013
05:37 AM
|
0
|
0
|
1199
|
|
POST
|
You can store custom tool bars in an mxd created via the menu option customize > customize mode route and then say distribute an mxd. You need to go to menu option customize > customize mode > Options tab and click on "Save all customizations to the document". This is something that appeared in 10.0.
... View more
09-12-2013
12:40 AM
|
0
|
0
|
2157
|
|
POST
|
You say "...let a user define a custom Toolbar with custom commands and menus on the fly and make them persistent". Is that not what the desktop menu option customize > customize mode all about? This allows the user to create a toolbar, drag any existing tool onto it and have their own customized toolbar? Look here on customizing a map document.
... View more
09-11-2013
03:03 AM
|
0
|
0
|
2157
|
|
POST
|
Aah... there is your problem, you are using Excel. Best bit of advice I can give to anyone is to avoid Excel like the plague! Because you can type anything into it people usually do and its always a formatting issue. I also find it flakey when trying to import data. So select the cells, headers and rows that contain the data and save as a CSV file. Use that to create a XY layer.
... View more
09-11-2013
02:51 AM
|
0
|
0
|
1763
|
|
POST
|
Correct Python AddIns only appeared in 10.1 so do not exist in 10.0 You say your tasks are to create toolbars with commands/menu but you don't say what these will actually do, this is what I was trying to get at? Are you intending to do complex fine grain manipulation of geometries (then ArcObjects is the way to go) or call upon existing geo-processing tools to improve a workflow (then may be python is your answer)? Why can't you use the addin wizard? With this you create the toolbar and controls, attach your code and then you have an addin which can be easily installed and distributed.
... View more
09-11-2013
02:12 AM
|
0
|
0
|
2157
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 4 weeks ago | |
| 3 | a month ago | |
| 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 |
3 weeks ago
|