Hello everyone
Its looks like these two cases produce the same results:
querySAOall = populated with a condition
# Make feature layer from my input data
arcpy.MakeFeatureLayer_management(inSAO, "LayerAll")
# Select by attribute and switch the selection
arcpy.SelectLayerByAttribute_management ("LayerAll", "NEW_SELECTION", querySAOall)
arcpy.SelectLayerByAttribute_management ("LayerAll", "SWITCH_SELECTION")
or:
# Make feature layer from my input data
arcpy.MakeFeatureLayer_management(inSAO, "LayerAll", querySAOall)
# Select by attribute and switch the selection
arcpy.SelectLayerByAttribute_management ("LayerAll", "SWITCH_SELECTION")
For me in the second case, the second "arcpy.SelectLayerByAttribute_management" line should return 0 because it is trying to select from a "SWITCH_SELECTION", and in the previous arcpy.MakeFeatureLayer_managemen we only select records with the condition querySAOall
arcpy.MakeFeatureLayer_management(inSAO", "LayerAll", querySAOall) arcpy.SelectLayerByAttribute_management ("LayerAll", "SWITCH_SELECTION")
Please advise.
I dont think the query in makefeaturesmanagement is making a layer where those features matching the query are selected, rather it is creating a layer which is a subset which matches the query.
The switch selection is therefore taking none selected to all selected.
David is correct, passing an SQL WHERE clause to MakeFeatureLayer creates a layer with a DefinitionQuery set to the SQL WHERE clause. The definition query is separate from selections and applies before the Select By tools.