laptop and a wrench

漏洞

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
漏洞 ID 编号 BUG-000180673
已提交November 3, 2025
上次修改时间November 11, 2025
适用范围ArcGIS Pro
找到的版本3.3.6
操作系统Windows OS
操作系统版本11.0 64 bit
状态Under Consideration

解决办法

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.

重现步骤

漏洞 ID: BUG-000180673

软件:

  • ArcGIS Pro

当漏洞状态发生变化时获得通知

下载 Esri 支持应用程序

发现关于本主题的更多内容

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项