<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Making a Python Toolbox - Need Help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1304626#M68072</link>
    <description>&lt;P&gt;Thanks for the help everyone.&amp;nbsp; I have decided to switch gears and use a stand alone script and import it.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 19:03:44 GMT</pubDate>
    <dc:creator>EvanMyers1</dc:creator>
    <dc:date>2023-06-29T19:03:44Z</dc:date>
    <item>
      <title>Making a Python Toolbox - Need Help</title>
      <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303173#M68025</link>
      <description>&lt;P&gt;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".&lt;/P&gt;&lt;P&gt;I have several functions in the .pyt code, and at the bottom I have the typical "if __name__ == '__main__':" at the bottom.&amp;nbsp; Is this wrong?&amp;nbsp; My script is several hundred lines long so here is a shorted version:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Jun 2023 20:57:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303173#M68025</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-06-26T20:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Python Toolbox - Need Help</title>
      <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303175#M68026</link>
      <description>&lt;P&gt;dedent lines 33- onward&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 21:10:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303175#M68026</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-06-26T21:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Python Toolbox - Need Help</title>
      <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303493#M68034</link>
      <description>&lt;P&gt;Thanks for the reply.&amp;nbsp; I Fixed the indentation issue but now I am getting 'setup is not defined' when I check the syntax.&amp;nbsp; I looked at examples and they all included the 'self' variables so I added those (I don't know what its for), and now its saying 'NameError: name 'self' is not defined'.&lt;/P&gt;&lt;P&gt;All I'm trying to do is get my script to run in a Python Toolbox so I can reference it in a C# script (another headache).&amp;nbsp; Is any of this class, self, stuff needed?&amp;nbsp; Seems much more complex than a normal toolbox.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 17:47:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303493#M68034</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-06-27T17:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Python Toolbox - Need Help</title>
      <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303642#M68044</link>
      <description>&lt;P&gt;That won't work.&amp;nbsp; Python Toolboxes aren't scripts. They are libraries and as such don't really get run, they get imported, the Tool class is instantiated and the tools execute method is called. You are missing all the required Tool methods (execute, getParameterInfo, isLicensed etc...)&lt;/P&gt;&lt;P&gt;I think what you need is a simple script, either standalone or attached to a regular toolbox.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 21:41:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1303642#M68044</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2023-06-27T21:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Python Toolbox - Need Help</title>
      <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1304136#M68062</link>
      <description>&lt;P&gt;Best way to start is to create the .pyt from the ArcGIS Pro catalog window which will give you a complete framework stub ready to go with all the required pieces.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 19:16:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1304136#M68062</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2023-06-28T19:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Python Toolbox - Need Help</title>
      <link>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1304626#M68072</link>
      <description>&lt;P&gt;Thanks for the help everyone.&amp;nbsp; I have decided to switch gears and use a stand alone script and import it.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 19:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-a-python-toolbox-need-help/m-p/1304626#M68072</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-06-29T19:03:44Z</dc:date>
    </item>
  </channel>
</rss>

