Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Restore Excluded features

$
0
0
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.

I appreciate it if somebody helps me please.

Code:


# Import modules
import arcpy
from arcpy import env

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

layerObject = arcpy.mapping.Layer("CHS_Chart_Extents")
arcpy.SelectLayerByAttribute_management ("CHS_Chart_Extents", "SWITCH_SELECTION")


# 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:

  queryList = selectedFids.replace(';', ',')
  newName = arcpy.AddFieldDelimiters("CHS_Chart_Extents", "FID")
  layerObject.definitionQuery =  '{0} not in ({1})' .format(newName, queryList)
  arcpy.RefreshActiveView()       
arcpy.SelectLayerByAttribute_management ("CHS_Chart_Extents", "SWITCH_SELECTION")


Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images