I'm having issues troubleshooting how to get my python code to automatically add my output layer to my current map in ArcPRO. I've included the code snippet below along with my error.
Snippet:
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.listMaps("Map")[0]
newLayer = (("FinalSurveyPts" + "_" +str(projName +".shp")))
aprxMap.addLayer(newLayer)
aprx.save()
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
del aprx
Error: Traceback (most recent call last):
File "D:\Grid Tool\Goshawk Survey Grid Tool.py", line 144, in <module>
aprxMap.addLayer(newLayer)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 2560, in addLayer
return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))
ValueError: FinalSurveyPts_WaltonPeak.shp
source https://stackoverflow.com/questions/77455735/adding-output-layer-with-python
Comments
Post a Comment