Hello,
I don't know why this script doesn't work. When I run it from a window in arcgis pro it works but like stand-alone script it doesn't work. It does not print any error, but no layer is selected and created in the resulting pdf. Can anyone advise me please?
The line that icludes SelectLayerByAttribute_management() is probably the whats bailing on on. You need to Make Feature Layer (Data Management)—ArcGIS Pro | Documentation first in a standaone script. ArcGIS Pro is foing that for you under the hood.
(PS: if you use the syntax highlighter, we can reference line numbers in your code...)
Joe, at some point in the early days of Pro (I don't think it was 1.x), Esri made the change where Select Layer By Attribute/Location takes data sets as well as layers/views. When passed a data set, the tool will create a layer/view, and that behavior is the same whether run within Pro application or stand-alone script. Personally, I have found the behavior odd, if not buggy, at times. I don't think there was anything wrong with making the user create a layer/view first, after all, the tools are called Select Layer By Attribute/Location.
In this case, the OP is passing a layer name (not a data set name) to a layer that hasn't been created, so you are most likely correct that line is causing the issue.