# Description: Passes selection from one DataFrame to another for the same layer. # Usage: Designed to be run in Python Command line window. Code assumes layers are Shapefiles and a selection actually exists # Author: Duncan Hornby # Created: 27/11/13 import arcpy # Get map document and list of DataFrames, code assumes only 2 exist mxd = arcpy.mapping.MapDocument("CURRENT") l = arcpy.mapping.ListDataFrames(mxd) # Get DataFrames df1 = l[0] df2 = l[1] # Get layer from first dataframe and create a list of select FIDs layername = "yr89_clipped_water_as_polygons" # Change this to your layer name l1 = arcpy.mapping.ListLayers(mxd,layername,df1)[0] d = arcpy.Describe(l1) fids = d.FIDSet toselect = fids.replace(";",",") # Get second identical layer in second dataframe and do selection l2 = arcpy.mapping.ListLayers(mxd,layername,df2)[0] sQuery = '"FID" IN (' + toselect + ')' arcpy.SelectLayerByAttribute_management(l2,"NEW_SELECTION",sQuery)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.