Hornbydd

Python problem: How to get workspace of a FeatureLayer?

Discussion created by Hornbydd on Dec 8, 2010
Latest reply on Dec 9, 2010 by jvondracek
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

Outcomes