ArcGIS Pro 2.5
The Layer to KML GP Tool from the standard TBX works fine.
The ArcPy code will work in the Python window.
The ArcPy code will even run and produce the KMZ from an IDE (such as Spyder).
The ArcPY code completes without error when run as a Script Tool in Pro, but no output is produced.
Can anyone else test this? I'm losing my mind trying to figure this out.
<SPAN class="keyword token">import</SPAN> arcpy
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"C:\Users\JackTorrance\Documents\ArcGIS\scratch\export\ExportTestAgain333.shp"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ExportedFeaturesLayer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"ExportedFeaturesLayer"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>getOutput<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>LayerToKML_conversion<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"ExportedFeaturesLayer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"D:\\TEMP\\TryThis.kmz"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I added the message simply to ensure the feature layer was valid (contains features), and you can see this working as expected in the GP messaging dialog.
One other observation: the script tool takes way longer than it should, like 2.5 minutes!