get list of highlighted features within a selection

3779
3
03-14-2014 01:30 AM
GuillaumeMOCCAND
Deactivated User
Hi,

from arcpy (in arcmap) i can get all selected feature within a layer using :

rows = arcpy.SearchCursor("myLayerNBame")

But it will list all selected feature that appear (in blue in the attribute table).
I need to get only the features that are highlighted in the selection (in yellow in the attribute table).

Does arcpy offers a solution for this ?

Thanks
Tags (2)
0 Kudos
3 Replies
DaveBarrett
Deactivated User
Hi,

Not sure this is possible but the following post has a way for getting the selected features.

http://forums.arcgis.com/threads/97774-arcpy-mapping-getting-the-selected-features-of-one-data-frame...

Your best bet is to select the layer by attributes with the options o select from current selection.

This will have the same results

Thanks

Dave
0 Kudos
GuillaumeMOCCAND
Deactivated User
2 diffrent solutions for only selected features but not the highlighted ones :

# Import arcpy module
import arcpy

#Layer that have already a selection ans some feature highlighted :
layerName = "PARCELS"

# first way to count selected features
rows = arcpy.SearchCursor(layerName)
i = 0
for row in rows:
    i=i+1

# second way to count selected features
d = arcpy.Describe(layerName)
fids = d.FIDSet

#print results : 
arcpy.AddMessage("loop count : " + str(i)) 
arcpy.AddMessage("desc count : " + str(len(fids.split(";"))))


But I need to get only the highlighted ones ...
0 Kudos
RichardFairhurst
MVP Alum
2 diffrent solutions for only selected features but not the highlighted ones :

# Import arcpy module
import arcpy

#Layer that have already a selection ans some feature highlighted :
layerName = "PARCELS"

# first way to count selected features
rows = arcpy.SearchCursor(layerName)
i = 0
for row in rows:
    i=i+1

# second way to count selected features
d = arcpy.Describe(layerName)
fids = d.FIDSet

#print results : 
arcpy.AddMessage("loop count : " + str(i)) 
arcpy.AddMessage("desc count : " + str(len(fids.split(";"))))


But I need to get only the highlighted ones ...


Doing this through programming has no interfaces in .Net, and therefore it would be impossible with Python.  Python only provides interfaces to a relatively small set of common map manipulations compared to .Net.  But even for .Net there does not seem to be a direct way of working with any kind of highlighted records interface, class or method.  The only .Net Interface I have seen to control the actual Table View window seen by the user in Desktop (ITableWindow3) has a toggle status property to change whether or not only selected records are shown (ShowSelected).  But it also says it only supports a SelectionSet when all rows are shown (making highlighted selections impossible).  So you can detect when the window is only showing selected records, but to do anything with the selection you have to toggle out of that display to show all records.

The only code I found that seemed to deal with it at all (in .Net) is in this post.  But it seems like the programmer would have to create and manage every highlight behavior if this is the only code that works and it seems this is not using the built in highlighting behaviors at all.  Perhaps ESRI programmers have access to interfaces that they are not exposing to end users.

Anyway, if .Net does not have any well defined interface to work with highlighted records in the Desktop Table Window the user sees, Python definitely won't.
0 Kudos