漏洞 ID 编号 |
BUG-000125587 |
已提交 | September 26, 2019 |
上次修改时间 | June 5, 2024 |
适用范围 | ArcGIS Pro |
找到的版本 | 2.4.1 |
操作系统 | Windows OS |
操作系统版本 | 10.0 |
状态 | As Designed
经开发团队审核,已确定此行为符合设计。 有关详细信息,请参阅“其他信息”部分。
|
附加信息
The MakeFeatureLayer_management tool does not return a layer object but instead a result object. Extract the layer from the result using the appropriate index. In this case, it is [0].
The object at index 0 in the result object is the layer to add. Use the following code:
temp = arcpy.MakeFeatureLayer_management(r"C:\Temp\GreatLakes\GreatLakes.gdb\GreatLakes", "TestOutput")[0]
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
m.addLayer(temp)
解决办法
The object at index 0 in the result object is the layer to add Use the following code:
temp = arcpy.MakeFeatureLayer_management(r"C:\Temp\GreatLakes\GreatLakes.gdb\GreatLakes", "TestOutput")[0]
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
m.addLayer(temp)
重现步骤