Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to get the search the field value

'SURFACE LOCATION%' in column 'RefName' in layer '*.dwg Annotation'

This is what I have so far...

# Find the Dataframe
df = arcpy.mapping.ListDataFrames(mxd, "Project Area")[0]

#Find the table named "*.dwg Annotation"
Table = arcpy.mapping.ListLayers(mxd, "*.dwg Annotation", df)[0]

whereClause = """RefName" LIKE 'SURFACE LOCATION%'""" % RefName

Anno = arcpy.SelectLayerByAttribute_management(AnnoTable, "NEW_SELECTION", whereClause)

Right now "Table" outputs the group layer name and the layer name.

However The link below shows that the the file path of the layer to work with SelectByAttribute.

Thoughts on how to get the file path of the layer?

and many thanks.

share|improve this question
I'm not clear on what you mean by "the string contained within a layer" - can you perhaps re-phrase your question to make what you are after more obvious, please? – PolyGeo May 22 '12 at 23:42
up vote 0 down vote accepted

ListLayers returns a list of Layer objects. You can use the names of layers as input to geoprocessing tools just as easily as paths to layers, so long as they exist in the current process.

So using either (returns the layer name) or Layer.dataSource (returns the full path to the layer) should work.

Additionally you might want to use AddFieldDelimiters to make your query expression workspace-agnostic.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.