<?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: Can someone tell me why this python toolbox is throwing a &amp;quot;parameters need repair&amp;quot; error? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099800#M62495</link>
    <description>&lt;P&gt;You could do it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class DummyTool
    def getParameterInfo(self):
        param0 = arcpy.Parameter(
            displayName="Choice One",
            name="input_choice_1",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input"
        )
        param0.filter.list = ["Polygon"]

        params = [param0]
        return params&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Sep 2021 15:18:00 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-09-20T15:18:00Z</dc:date>
    <item>
      <title>Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099546#M62478</link>
      <description>&lt;P&gt;Unfortunately, programming python toolboxes is not very well documented by Esri.&amp;nbsp; I can't find any good examples anywhere of what a fully, completed toolbox with validation and source code should look like.&amp;nbsp; It also seems like "parameters" and "messages" behave as magic arcpy variables that don't need to be expressly instantiated; I'm having trouble finding explicit guidance/documentation on that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either way, could someone who has done this take a look at my code and help me understand why it's failing?&lt;/P&gt;&lt;P&gt;The validation code works just fine, but every time I run it, it yields the somewhat cryptic error 000820: The parameters need repair.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

class Toolbox(object):
    def __init__(self):
        self.label = "ToolboxTest"
        self.alias = ""
        self.tools = [DummyTool]


class DummyTool(object):
    def __init__(self):
        self.label = "DummyTool"
        self.description = "A dummy tool"
        self.canRunInBackground = False

    def getParameterInfo(self):
        p = arcpy.mp.ArcGISProject('CURRENT')
        m = p.activeMap

        param0 = arcpy.Parameter(
            displayName="Choice One",
            name="input_choice_1",
            datatype="GPLayer",
            parameterType="Required",
            direction="Input"
        )

        poly_list = [] # list only polygon feature layers
        for lyr in m.listLayers():
            desc = arcpy.Describe(lyr)
            if desc.dataType == "FeatureLayer":
                if desc.shapeType == "Polygon":
                    poly_list.append(lyr.name)
        param0.filter.type = "ValueList"
        param0.filter.list = poly_list

        params = [param0]
        return params

    def isLicensed(self):
        return True

    def updateParameters(self, parameters):
        pass

    def updateMessages(self, parameters):
        return True

    def execute(self, parameters, messages):
        # All I want to do here is just access
        # the parameter value and report some
        # facts about it for testing
        self.updateParameters(parameters)
        
        lyr = parameters[0].value
        d = arcpy.Describe(lyr)
        arcpy.AddMessage(d.name)
        arcpy.AddMessage(d.dataType)
        arcpy.AddMessage(d.shapeType)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099546#M62478</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2021-09-20T19:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099564#M62481</link>
      <description>&lt;P&gt;I was able to get it to work by changing the data type of the input variable from GPLayer to GPString.&amp;nbsp; I have no idea why, but this is typical with toolbox programming in that you just have to keep trying things until you find something that works.&amp;nbsp; I guess in a way it makes sense since you really are just setting it to a string and not a layer object. On line 28 you also have to initialize the variable (eg poly_list = []). Good luck on your tool, the fun is just beginning &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 21:48:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099564#M62481</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2021-09-17T21:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099800#M62495</link>
      <description>&lt;P&gt;You could do it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class DummyTool
    def getParameterInfo(self):
        param0 = arcpy.Parameter(
            displayName="Choice One",
            name="input_choice_1",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input"
        )
        param0.filter.list = ["Polygon"]

        params = [param0]
        return params&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 15:18:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099800#M62495</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-20T15:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099935#M62500</link>
      <description>&lt;P&gt;Hi Don, your suggestion worked, (and I did instantiate the list, I just failed to put it in the example) but this part:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;this is typical with toolbox programming in that you just have to keep trying things until you find something that works&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;is what is so frustrating.... show me the book I'll buy it, or tell me which class to attend and I'll register for it - it's the poking around in the dark that is so maddening!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still this did work so thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 14:58:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099935#M62500</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2021-09-20T14:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099938#M62501</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt; that just gives me one option in the parameter drop-down called "Polygon."&amp;nbsp; What I'm looking for is a filter list of only the Polygon type feature layers&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 15:01:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099938#M62501</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2021-09-20T15:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099946#M62502</link>
      <description>&lt;P&gt;Sorry, I should have tested it...&lt;/P&gt;&lt;P&gt;It works with datatype GPFeatureLayer and not setting the filter type.&lt;/P&gt;&lt;P&gt;I edited the post above accordingly for future reference.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 15:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099946#M62502</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-20T15:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099990#M62504</link>
      <description>&lt;P&gt;Hi EricEagle,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a bug in your code at line 28, where you did not set polylist to any value. Set this to an empty list and your code works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;poly_list = []  # list only polygon feature layers&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Alternative Solution&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;*Edit*&amp;nbsp;JohannesLinder beat me to this solution while I was writing this out =D. I'll leave it below here anyways:&lt;/P&gt;&lt;P&gt;You can accomplish what you are trying to do more concisely by changing dataType to "GPFeatureLayer". You can then choose a "Featureclass" filter type. Note that the default filter type for GPFeatureLayer&amp;nbsp;is&amp;nbsp;"Featureclass", so there is actually no need to explicitly specify this as in the example below. You can safely omit the line param0.filter.type = "Featureclass".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;param0 = arcpy.Parameter(
            displayName="Choice One",
            name="input_choice_1",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input"
        )
param0.filter.type = "Featureclass"
param0.filter.list = ["Polygon"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is in action:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HannesZiegler_0-1632153766104.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/23393iF87858274D62A05C/image-size/large?v=v2&amp;amp;px=999" role="button" title="HannesZiegler_0-1632153766104.png" alt="HannesZiegler_0-1632153766104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also note that you won't be able to do the same with the&amp;nbsp;GPLayer&amp;nbsp;data type. The reason&amp;nbsp;GPLayer&amp;nbsp;doesn't have a data filter type is because&amp;nbsp;GPLayer&amp;nbsp;is for any Layer (which includes tables, raster, etc.) and&amp;nbsp;GPFeatureLayer&amp;nbsp;is explicitly only the subset of Layers with features (Feature Class, Shapefile).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;More Info&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can find this in the doc &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/defining-parameters-in-a-python-toolbox.htm" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;There's an example of a fully fleshed out Python toolbox &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/a-quick-tour-of-python-toolboxes.htm" target="_self"&gt;here&lt;/A&gt;, though it doesn't cover your exact case (it'd be difficult to cover every case in the doc).&lt;/P&gt;&lt;P&gt;Also, check out recent presentations on creating toolboxes &lt;A href="https://www.youtube.com/watch?v=y84onLbW-_M&amp;amp;t=1399s" target="_self"&gt;here&lt;/A&gt;, where parts of this topic are covered (haven't watched this one in a while, it might not cover your exact use case but might provide some more insights).&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 16:51:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1099990#M62504</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2021-09-20T16:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone tell me why this python toolbox is throwing a "parameters need repair" error?</title>
      <link>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1100043#M62505</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/50334"&gt;@HannesZiegler&lt;/a&gt;Very helpful - thanks for all the resources.&amp;nbsp; In the original code, I did instantiate the poly_list variable, but I wrote this on another network and messed up when retyping it here.&lt;/P&gt;&lt;P&gt;I really like the ability that toolboxes give me to maintain 100% of my code in git and not having to worry about updating/moving around .tbx files.&amp;nbsp; It's not practical for every case but feels like a lot cleaner way to work.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:07:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-someone-tell-me-why-this-python-toolbox-is/m-p/1100043#M62505</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2021-09-20T19:07:50Z</dc:date>
    </item>
  </channel>
</rss>

