laptop and a wrench

Error

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
Número de ID del error BUG-000180673
EnviadoNovember 3, 2025
Última modificaciónNovember 11, 2025
Relacionado conArcGIS Pro
Versión encontrada3.3.6
Sistema operativoWindows OS
Versión de sistema operativo11.0 64 bit
EstadoUnder Consideration

Solución alternativa

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.

Pasos para reproducir

ID del error: BUG-000180673

Software:

  • ArcGIS Pro

Recibir notificaciones cuando cambie el estado de un error

Descargar la aplicación de soporte de Esri

Descubrir más sobre este tema

Obtener ayuda de expertos en ArcGIS

Contactar con el soporte técnico

Descargar la aplicación de soporte de Esri

Ir a opciones de descarga