laptop and a wrench

漏洞

The following error message, "AttributeError: 'str' object has no attribute 'fields’", is returned when running the script tool from the Python toolbox.

ArcGIS Pro
漏洞 ID 编号 BUG-000164466
已提交January 21, 2024
上次修改时间March 19, 2025
适用范围ArcGIS Pro
找到的版本3.1.3
操作系统Windows OS
操作系统版本10.0 64 Bit
状态Will Not Be Addressed

附加信息

It is recommended to pass the name of the feature layer to the tool and set the symbology of the feature layer fetched from the map. This is more efficient than creating an output feature layer parameter to set the symbology.

解决办法

Code to take an input feature layer, where p0 is the text name of the feature layer, and update the symbology from the layer as fetched from the active map.

p0 = parameters[0].valueAsText # set p0 in the pyt p0 = arcpy.GetParameterAsText(0) #set p0 in the script tool, aprx = arcpy.mp.ArcGISProject('CURRENT') lyr = aprx.activeMap.listLayers(p0)[0] symb = lyr.symbology symb.updateRenderer('UniqueValueRenderer') symb.renderer.fields = ['LABEL'] lyr.symbology = symb.

Otherwise, for a script tool, create an output feature layer parameter that is derived from the input layer. In this scenario, p0 is set to p0 = arcpy.GetParameter(0) in the main function. Then, at the end of the execution, set the output parameter: sym = p0.symbology sym.updateRenderer('UniqueValueRenderer') sym.renderer.fields = ['LABEL'] p0.symbology = sym arcpy.SetParameter(1, p0)

重现步骤

漏洞 ID: BUG-000164466

软件:

  • ArcGIS Pro

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

下载 Esri 支持应用程序

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

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项