I'm trying to move some Python 2.7 scripts from ArcMap 10.4 to Python 3.4 and ArcGIS Pro 1.3.1. I'm having difficulty understanding why I cannot reference layers in the Table of Contents directly by name (see 1st screenshot). I am able to do this in ArcMap (see second screenshot).
There is exactly one address point selected in each environment and the layer is renamed in the table of contents to "addresspoints" in each environment.
I know I could just rewrite the script to use a "full path" to the layer OR set my arcpy.env.workspace (which in both cases here is NOT set to the Enterprise GDB where addresspoints lives) and use the full name of the feature class but I would very much like to understand why this isn't working and if it is by design or if it is a bug.
myLayer = 'addresspoints' ftrCount = int(arcpy.GetCount_management(myLayer).getOutput(0)) ftrCount
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 14999, in GetCount raise e File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 14996, in GetCount retval = convertArcObjectToPythonObject(gp.GetCount_management(*gp_fixargs((in_rows,), True))) File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Rows: Dataset addresspoints does not exist or is not supported Failed to execute (GetCount).