msayler-w

Layer getting copied erroneously

Discussion created by msayler-w on Nov 8, 2012
Latest reply on Oct 29, 2013 by msayler-w
In a nutshell, I have DDP-enabled mxd I'm using to automate the generation of sets of maps. I'm dynamically updating a location map dataframe by selecting some features using SelectLayerByAttribute_management, zooming to the features, and then deselecting the features. I have my script working when using "CURRENT" for the map doc and am in the process of trying to get it to work outside the MXD using the actual map doc path.

I noticed when testing with "CURRENT" that the layer being selected would get copied to the active dataframe. I changed my code to switch the active dataframe before running the select/deselect and then change it back after. This seemed to fix things until I started using the actual mxd path; then the copy behavior returns. If I have the mxd open, it copies the layer. Even if I'm in an empty document, it will copy the layer into the empty dataframe.

Here is my code for the function:
### Select/Zoom To/Deselect Layer ###
def SZD(mapDocument, layer, dataFrame, query=""):
    '''Docstring'''
    #activate data frame to prevent layer from being copied into a different one
    mapDocument.activeView = dataFrame
    
    arcpy.SelectLayerByAttribute_management(layer,"NEW_SELECTION", query)
    dataFrame.zoomToSelectedFeatures()
    arcpy.SelectLayerByAttribute_management(layer,"CLEAR_SELECTION")


After running this, I run something like the following to reset things:
mxd.activeView = mainDF
mxd.activeView = "PAGE_LAYOUT"


I'm working in ArcGIS 10.0 and running through Citrix.

Has anyone encountered this issue and/or figured out how to avoid it? Will this likely be a non-issue when running outside ArcMap?

Outcomes