for df in arcpy.mapping.ListDataFrames(mxd, "DFMAIN"):
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
# do some processing here
for df in arcpy.mapping.ListDataFrames(mxd, "DFINSET"):
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
# do some processing here
Some how this just doesn't seem right, you're getting a list of exactly one df and then 'looping' through it. Are you doing different things in the 'do some processing here' part for each dataframe?I think i'd be more tempted to approach this this way:df_list = arcpy.mapping.ListDataFrames(mxd)
for df in df_list:
if df == "DFMAIN":
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
# do some processing here
else: #since there are only two layers you don't need to test here for which df this is
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
# do some processing here
I know its niggling but I think it gets away from the problem you are experiencing with the active dataframe being the first one that is selected.