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.

  • 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
    Commented May 22, 2012 at 23:42

1 Answer 1


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 Layer.name (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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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