laptop and a wrench

Bogue

When performing a selection via a search cursor on subtype group layers in Python, there are missing results when comparing it to Select By Attributes.

ArcGIS Pro
Numéro d’ID de bogue BUG-000180673
EnvoiNovember 3, 2025
Dernière modificationNovember 11, 2025
S’applique àArcGIS Pro
Version trouvée3.3.6
Système d’exploitationWindows OS
Version du système d’exploitation11.0 64 bit
StatutUnder Consideration

Solution de contournement

Check if the layer is a subtype group layer and if there are child layers. If these child layers exist query each layer individually. This also makes a list of non-subtyped layers and child Subtype layers for editing. Refer to the example below:

def get_un_layers2(currentmap,selection_only: bool):

  # This function gathers known UN Subtype Group Layers, iterates through them,

  # and returns a list of editable Layers and Subtype Layers.

  # The selection_only = True option sets the function to only return layers with an active selection set.

  arcpy.AddMessage(f'Getting UN Layers')

  arcpy.AddMessage(f'Only process UN layers with selected features? {selection_only}')

  top_level_layers = []

  un_layers = []

  un_layer_names = ['Stormwater Device',

           'Stormwater Junction',

           'Stormwater Line',

           'Structure Boundary']

  all_layers = currentmap.listLayers()

  for layer in all_layers:

    if layer.name in un_layer_names:

      top_level_layers.append(layer)

      # arcpy.AddMessage(f'Found expected Top Level layer: {layer.name}')

    del layer

  for layer in top_level_layers:

    subtype_group_layer = layer.listLayers()

    if subtype_group_layer:

      for subtypelayer in subtype_group_layer:

        if selection_only is True:

          if subtypelayer.getSelectionSet():

            un_layers.append(subtypelayer)

            # arcpy.AddMessage(f'Found Subtype Layer: {subtypelayer.longName}')

        elif selection_only is False:

          un_layers.append(subtypelayer)

          # arcpy.AddMessage(f'Found Subtype Layer: {subtypelayer.longName}')

        del subtypelayer

    else:

      if selection_only is True:

        if layer.getSelectionSet():

          un_layers.append(layer)

          # arcpy.AddMessage(f'Found Non-Subtyped Top Level Layer: {layer.longName}')

      elif selection_only is False:

        un_layers.append(layer)

        # arcpy.AddMessage(f'Found Non-Subtyped Top Level Layer: {layer.longName}')

    del layer

  if not un_layers:

    arcpy.AddError('No UN layers found. Check for active selection if using selection_only = True option.')

    sys.exit()

  return un_layers2

Clearing the selection first and using the same where clause in the cursor returns the correct results.

Étapes pour reproduire

ID de bogue: BUG-000180673

Logiciel:

  • ArcGIS Pro

Recevoir une notification lorsque le statut d’un bogue change

Télécharger l’application Esri Support

En savoir plus sur ce sujet

Obtenir de l’aide auprès des experts ArcGIS

Contacter le support technique

Télécharger l’application Esri Support

Accéder aux options de téléchargement