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.
import arcpy
arcpy.env.overwriteOutput = True
arcpy.MakeFeatureLayer_management(r"C:\Users\JackTorrance\Documents\ArcGIS\scratch\export\ExportTestAgain333.shp", "ExportedFeaturesLayer")
arcpy.AddMessage(arcpy.GetCount_management("ExportedFeaturesLayer").getOutput(0))
arcpy.LayerToKML_conversion("ExportedFeaturesLayer", "D:\\TEMP\\TryThis.kmz")
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!
Solved! Go to Solution.
From Support Services:
We finished the testing and confirmed and attached the following defect to your case:
BUG-000129805 : Running the python command for Layer to KML works in idle, but fails to create output if run from script tool.
Lame. We are in the process of updating all of our existing GP services to Pro/Python 3.x based tools. This roadblocks updating one of our most used GP widgets which will now have to remain ArcMap/Python 2.x based for the foreseeable future.
script tool ... as in a script attached to a tool in a toolbox?
what are the parameters you have specified?
Conventional script tools require that the parameters be specified as input, derived or output.
The code you have posted seems to be that used in an IDE which should work there as you have found
Hi Dan,
I dumbed th code way down for purpose of isolation. No parameters set in the script tool for this test. I have tried a number of different input types and output locations.
Humor me and toss that in a script tool and let me know if it works for you. This may be a bug.
/blogs/dan_patterson/2016/05/19/toolbox-creation-in-arcgis-pro
I would have to rewrite your code to specify your hardcoded paths to work in a conventional python tool
Dan, I tossed this into a script tool with the script imported. The TBX is zipped and attached above. The output location will be a folder called 'export' in your scratch folder. Thanks!
From Support Services:
We finished the testing and confirmed and attached the following defect to your case:
BUG-000129805 : Running the python command for Layer to KML works in idle, but fails to create output if run from script tool.
Lame. We are in the process of updating all of our existing GP services to Pro/Python 3.x based tools. This roadblocks updating one of our most used GP widgets which will now have to remain ArcMap/Python 2.x based for the foreseeable future.
Has anyone had luck with this since the original post? I'm experiencing the exact same issue, using Pro 2.9.5 and a colleague is seeing the same thing with Pro 3.
Trying to add the Layer to KML tool into a custom GP tool (modifying the Data Extract script tool to add KML and JSON export options) and the script will run successfully and create a zipped folder, but the tool doesn't run, the zipped folder is empty, and it throws a warning saying that I need the Data Interoperability extension.
We were able to remedy this by changing the configuration in the pick list of the format type parameters. I had the quotes set up wrong; things are working now that they are set up as below: