Searching for value in layer without opening MXD file?

المشرف العام

Administrator
طاقم الإدارة
As part of the validation for parameters of a Python toolbox, I need to check if the text in parameter #1 is exists in a layer in a MXD file selected as parameter #2. Currently, I use this code in updateMessages:

mxd = arcpy.mapping.MapDocument(parameters[2].valueAsText)layer = arcpy.mapping.ListLayers(mxd, "LayerName")[0]condition = u"Field=" + parameters[1].textwith arcpy.da.SearchCursor(layer.dataSource, ["Field"], condition) as cursor: #Do some stuff...The problem is that this takes very long time since the rather MXD large file has to be opened. It is not acceptable to have a two minute waiting time with ArcMap freezing every time the parameter validation is performed.

So my question is this: Is there any way to find the source of the layer, and search for a value in it, without having to open the MXD?



أكثر...
 
أعلى