I have an arcpy (ArcGIS Pro) script to rename layers to their original name. It only has one argument - The layer to be renamed, which the user selects from the table of contents.
At first, I thought I could just enter the argument's name ("Input_Layer") then ".dataSource" but of course you get the error telling you a string has no function 'dataSource.'
Input_Layer = arcpy.GetParameterAsText(0)
So, I loop through the layers, then find the the layer that has the same name. The problem with this is that it is often the case that more than one layer has the same name, and the first one gets picked whether I want it to or not.
Is there a way to reliably find the exact layer that the user chose when he selected from the table of contents?
Thank you,
Randy McGregor