When I try that code for selecting a different data frame it disappears from my table of contents.
I have a MXD with 5 data frames, the main data frame is running the Data Driven Pages for my Assessor Parcel Maps. The second data frame shows the Township and Range of the page, third data frame shows the section within the township and range, and the fourth data frame shows the different divisions within the section. I want to write a script that will prompt the user for those three pieces of information - TR, SECTION, and DIVISION - and have the page update automatically. In my limited Python Scripting I am having trouble selecting layers in non active data frames. The next step will be to map the selections according to users input...... import arcpymxd = arcpy.mapping.MapDocument ('CURRENT')df = arcpy.mapping.ListDataFrames(mxd) [1]mxd.activeView = dflayer = arcpy.GetParameterAsText (0)grid = arcpy.GetParameterAsText (1)arcpy.AddMessage (grid)selstring = "TAG LIKE " + "'" + grid + "'"arcpy.AddMessage("Selection string = " + selstring)arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)
import arcpy layer = arcpy.GetParameterAsText (0) grid = arcpy.GetParameterAsText (1) arcpy.AddMessage (grid) selstring = "TAG LIKE " + "'" + grid + "'" arcpy.AddMessage("Selection string = " + selstring) mxd = arcpy.mapping.MapDocument ('CURRENT') dfs = arcpy.mapping.ListDataFrames(mxd) for df in dfs: mxd.activeView = df arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)
ok, i get that syntax and it appears like it is working but I would like to select and activate that data frame. Maybe my question should have been, can I activate a data frame for my script to work?
df = arcpy.mapping.ListDataFrames(mxd)[2]
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.