babakkasraie

Restore Excluded features

Discussion created by babakkasraie on Mar 1, 2013
Hi

I have successfully created the following script to exclude unselected features using a definition query from my map.

My problem is that I don't know how to restore the excluded features and return them to my map layer again. In other words I have to undo the changes.



# Import modules
import arcpy
from arcpy import env

# Read from current map
mxd = arcpy.mapping.MapDocument("CURRENT")

# describe the feature layer to access the the selected set
desc = arcpy.Describe("CHS_Chart_Extents")

# FIDSet will contain the selected features
selectedFids = desc.FIDSet

# If there are selectedFids (a selection set), write them to a new feature
# class in the current workspace.
if len(selectedFids) > 0:
   layerObject = arcpy.mapping.Layer("CHS_Chart_Extents")
   queryList = selectedFids.replace(';', ',')
   newName = arcpy.AddFieldDelimiters("CHS_Chart_Extents", "FID")
   layerObject.definitionQuery =  '{0} in ({1})' .format(newName, queryList)
   arcpy.RefreshActiveView() 




In these codes there is a line for definition query which will remove unselected data from my map. If you go to layer property and go to definition query section you can see the removed features.


layerObject.definitionQuery =  '{0} in ({1})' .format(newName, queryList)



Now I need to return them to the map to make the map complete again.

I don't know how to do that.

I really appreciate it if somebody helps me.

Best regards

Babak

Outcomes