Looking for help with my script. I am getting an error on line 11 with ".kmz".
import arcpy
LineList = [381001,
691001]
LayerList = ["Structures","Transmission Circuit"]
for Line in LineList:
for Layer in LayerList:
kmlname = "\\fs01\Inspection Programs\CVI\2021\Inspections\Drone\" + str(Line) + "." + Layer + ".kmz"
sql = "legacycircuitid = '" + str(Line) +"'"
arcpy.management.SelectLayerByAttribute(Layer, 'NEW_SELECTION', sql)
arcpy.conversion.LayerToKML(Layer, kmlname)
Code formatting ... the Community Version - Esri Community
will provide line numbers and proper formatting... as it is shown now
Also, kmlname = "\\fs01\Inspection P.....
probably won't work since you haven't set an environment workspace in your script
Thanks, Dan.
I added in a specified output folder.
LineList = []
LayerList = ["Structures", "Transmission Circuit"]
OutputFolder = "H:\"
print("Preparing files")
for Line in LineList:
for Layer in LayerList:
kmlname = OutputFolder + str(Line) + "." + str(Layer) + ".kmz"
sql = "legacycircuitid = '" + str(Line) +"'"
arcpy.management.SelectLayerByAttribute(Layer, 'NEW_SELECTION', sql)
arcpy.conversion.LayerToKML(Layer, kmlname)
print("KMZ created for " + str(Line) + " " + str(Layer))
I'd like to import this into a gp tool so the engineers can simply specify the ID.
import arcpy
LineList = []
LayerList = ["Structures", "Transmission Circuit"]
OutputFolder = "H:\"
print("Preparing files")
for Line in LineList:
for Layer in LayerList:
kmlname = OutputFolder + str(Line) + "." + str(Layer) + ".kmz"
sql = "legacycircuitid = '" + str(Line) +"'"
arcpy.management.SelectLayerByAttribute(Layer, 'NEW_SELECTION', sql)
arcpy.conversion.LayerToKML(Layer, kmlname)
print("KMZ created for " + str(Line) + " " + str(Layer))
the last line of my comment... the script as it stands has no clue where to find those layers