|
POST
|
Joe, Sorry to bang on about this but I looked at the Help page you identified, a page I have looked at before but I see NO mention of the property (thanks for correcting me) Path. There is the property CatalogPath which you use on a dataset object but this actually returns something slightly different (with a shapefile). So where did you find out about the property Path? Duncan
... View more
12-09-2010
12:14 PM
|
0
|
0
|
1877
|
|
POST
|
Hi, Thats a good way of determining the workspace, but my question is where is the method Path documented in the Desktop help file? I find no mention of this method in the help file or object model! I get your point about placing this question in the other thread but I've always considered that to be about processing not annoying specifics of Python! Thanks for your help. Duncan
... View more
12-08-2010
11:36 PM
|
0
|
0
|
1877
|
|
POST
|
Python Gurus, As you all know there is the annoying problem of SQL syntax between different storage formats, by this I mean for a Personal Geodatabase a field is enclosed in [] whilst a file geodatabase has fields enclosed in "". I've recently became aware of a useful method of the geoprocessor AddFieldDelimiters that automates the correct enclosure based upon a workspace requirements. The Object Model diagram shows that the syntax is gp.AddfieldDelimiters(fieldname,workspace). Now I often expose my scripts as tools within ArcToolbox so my input parameters are usually a FeatureLayer. My problem is that having looked at the Object Model I can't work out how one gets a handle on the Workspace of a FeatureLayer which I could then use to feed into the AddfieldDelimiters method for building the correct SQL syntax. I thought the Describe method would help with this but it seems it is not possible. What I want to avoid is the user having to select not only the FeatureLayer but then navigate to it's Workspace in the ArcToolbox interface. So my question is simply how does one get the workspace of a featurelayer using the geoprocessor in Python? I am using ArcGIS 9.3. Duncan
... View more
12-08-2010
01:46 AM
|
0
|
7
|
5471
|
|
POST
|
Rory, Take a look at the desktop help file! It has hundreds of examples of how to script the geoprocessing tools in Python. Depending upon exactly what you want to do you may want to merge tables or append data to an existing table? Anyway search the help file for the Merge tool and at the bottom of the page there is always a short example of the tool being called using Python under the section Scripting syntax. Duncan
... View more
12-08-2010
01:24 AM
|
0
|
0
|
1233
|
|
POST
|
Greg, Here is the VBA code for loading a table into the map document: Sub test2()
' Get document
Dim pMXDocument As IMxDocument
Set pMXDocument = ThisDocument
' Get Map
Dim pMap As IMap
Set pMap = pMXDocument.FocusMap
' Get table collection
Dim pStandaloneTableCollection As IStandaloneTableCollection
Set pStandaloneTableCollection = pMap
' Create workspacefactory (for opening up dBase files)
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Dim pFeatureWorkSpace As IFeatureWorkspace
Set pFeatureWorkSpace = pWorkspaceFactory.OpenFromFile("C:\Temp", 0)
' Get dBase table
Dim pTable As ITable
Set pTable = pFeatureWorkSpace.OpenTable("testtable") ' note no .dbf
' Create StandaloneTable
Dim pStandaloneTable As IStandaloneTable
Set pStandaloneTable = New StandaloneTable
Set pStandaloneTable.Table = pTable
pStandaloneTable.Name = "My Table"
' Add table to Map
pStandaloneTableCollection.AddStandaloneTable pStandaloneTable
pMXDocument.UpdateContents
End Sub Duncan
... View more
11-30-2010
04:46 AM
|
0
|
0
|
1650
|
|
POST
|
Greg, Here is a simple bit of code in VBA to get you going. Sub test()
' Get document
Dim pMXDocument As IMxDocument
Set pMXDocument = ThisDocument
' Get Map
Dim pMap As IMap
Set pMap = pMXDocument.FocusMap
' Get table collection
Dim pStandaloneTableCollection As IStandaloneTableCollection
Set pStandaloneTableCollection = pMap
' Get a count of tables
Dim n As Integer
Let n = pStandaloneTableCollection.StandaloneTableCount
' Step through each table and print name
Dim pStandaloneTable As IStandaloneTable
Dim i As Integer
For i = 0 To (n - 1)
Set pStandaloneTable = pStandaloneTableCollection.StandaloneTable(i)
Debug.Print pStandaloneTable.Name
Next i
End Sub Duncan
... View more
11-28-2010
01:55 PM
|
0
|
0
|
1650
|
|
POST
|
Greg, To add or find a table in the map document you need to be using the IStandaloneTableCollection Interface. You can loop with this to compare names of tables in the collection. There is no "find the table with this name" function you must enumerate the collection. Duncan
... View more
11-27-2010
09:14 AM
|
0
|
0
|
1650
|