I have been trying to get a python toolbox working but no matter what I do, it always comes back with the red exclamation point "Click to repair project item".
I have several functions in the .pyt code, and at the bottom I have the typical "if __name__ == '__main__':" at the bottom. Is this wrong? My script is several hundred lines long so here is a shorted version:
import arcpy
import sys
import os
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Toolbox"
self.alias = "toolbox"
# List of tool classes associated with this toolbox
self.tools = [Tool]
class Tool(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def setup(sqlQuery):
print("ice cream")
def numberLS(lsOIDList, lsNoWW_NUM):
print("banana")
def numberManholes(mhOIDList, mhNoMH_NUM):
print("chocolate syrup")
def numberGravityMains(mhOIDList, grvmainOIDList, grvmainNoID)
print("peanuts")
if __name__ == '__main__':
# Global Environment settings
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject('current')
currentMap = aprx.activeMap
lyrList = currentMap.listLayers()
sqlQuery = "OWNEDBY = 1 AND LIFECYCLESTATUS = 'ACTIVE'"
setup(sqlQuery)
numberLS(lsOIDList, lsNoWW_NUM)
numberManholes(mhOIDList, mhNoMH_NUM)