laptop and a wrench

Bogue

The Map.addLayer command fails with ValueError when attempting to add a layer created with the MakeFeatureLayer_management and MakeRasterLayer_management tools.

Dernière publication: February 24, 2020 ArcGIS Pro
Numéro d’ID de bogue BUG-000125587
EnvoiSeptember 26, 2019
Dernière modificationJune 5, 2024
S’applique àArcGIS Pro
Version trouvée2.4.1
Système d’exploitationWindows OS
Version du système d’exploitation10.0
StatutAs Designed

Informations supplémentaires

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)

Solution de contournement

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)

Étapes pour reproduire

ID de bogue: BUG-000125587

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