<?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: Parameter B selection of features based on Parameter A Geodatabase -  Python Toolbox in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1345886#M69155</link>
    <description>&lt;P&gt;You have your gdb set to the feature dataset parameter in the List Featureclass which I think will return in an empty list.&amp;nbsp; You need to iterate through the gdb, by setting the arcpy.env.workspace to the gdb and use ListDatasets() with ListFeatureClasses to get them:&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;arcpy.env.workspace = gdb
 
if self.params[0].altered:
    _tmparray = []
    for ds in [ds for ds in arcpy.ListDatasets(feature_type='feature') if ds is not None and ds != '']:
            for fc in [fc for fc in arcpy.ListFeatureClasses(feature_dataset=ds) if fc not in fcExclude]:
                    # append featureclass string to the fc list
                    _tmparray.append(fc)
    fcFilter = self.params[1].filter
    fcFilter.list = _tmparray&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Adding the .altered flag to that param will execute the list filter each time a new gdb is selected.&lt;/P&gt;</description>
    <pubDate>Sat, 04 Nov 2023 15:12:57 GMT</pubDate>
    <dc:creator>StaticK</dc:creator>
    <dc:date>2023-11-04T15:12:57Z</dc:date>
    <item>
      <title>Parameter B selection of features based on Parameter A Geodatabase -  Python Toolbox</title>
      <link>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1340210#M69014</link>
      <description>&lt;P&gt;Hey folks,&lt;/P&gt;&lt;P&gt;New to python toolboxes.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;What I'm looking to do&lt;/P&gt;&lt;P&gt;parameter A -&amp;nbsp; user defined Geodatabase&lt;/P&gt;&lt;P&gt;parameter B -&amp;nbsp; list of features in parameter A or in datasets within parameter A the user can select one or more&lt;/P&gt;&lt;P&gt;Then the&amp;nbsp;&lt;SPAN&gt;execute code does thing to those selected features only&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm a bit stumped is this possible.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Current code&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-

import arcpy


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 = "Parcel Migration Data Conversion"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""

        # Create a geodatabase parameter
        geodatabase = arcpy.Parameter(
            displayName="Input Geodatabase",
            name="geodatabase",
            datatype="DEWorkspace",
            parameterType="Required",
            direction="Input")

        # Create a feature class parameter
        feature_classes = arcpy.Parameter(
            displayName="Feature Classes",
            name="feature_classes",
            datatype="DEFeatureClass",
            parameterType="Required",
            direction="Input",
            multiValue=True)
        

        
      
        #feature_classes.filter.list = []
        #feature_classes.parameterDependencies = [geodatabase.name] 

        # Add the parameters to a parameter list
        params = [geodatabase, feature_classes]

        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""

        gdb = parameters[0]

        fclist = []

        for fc in arcpy.ListFeatureClasses(feature_dataset=gdb):
            fclist.append(fc)
            
        parameters[1].filter.list = fclist

        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""

        ## do stuff code goes here

        "params[1] = list of features"
        return

    def postExecute(self, parameters):
        """This method takes place after outputs are processed and
        added to the display."""
        return&lt;/LI-CODE&gt;&lt;P&gt;Current script toolbox and geodatbase&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_0-1697836118985.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83633iB6BC2390F0137AB1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_0-1697836118985.png" alt="JS_Esri_0-1697836118985.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 21:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1340210#M69014</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2023-10-20T21:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter B selection of features based on Parameter A Geodatabase -  Python Toolbox</title>
      <link>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1340224#M69015</link>
      <description>&lt;P&gt;I think you need to define parameter B as GPValueTable and populate the ValueList filter with a list of feature class names.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/defining-parameters-in-a-python-toolbox.htm?#ESRI_SECTION1_E2BAA5D4440D41D6AAB948922186905A" target="_blank"&gt;Defining parameters in a Python toolbox—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 21:50:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1340224#M69015</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2023-10-20T21:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter B selection of features based on Parameter A Geodatabase -  Python Toolbox</title>
      <link>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1345886#M69155</link>
      <description>&lt;P&gt;You have your gdb set to the feature dataset parameter in the List Featureclass which I think will return in an empty list.&amp;nbsp; You need to iterate through the gdb, by setting the arcpy.env.workspace to the gdb and use ListDatasets() with ListFeatureClasses to get them:&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;arcpy.env.workspace = gdb
 
if self.params[0].altered:
    _tmparray = []
    for ds in [ds for ds in arcpy.ListDatasets(feature_type='feature') if ds is not None and ds != '']:
            for fc in [fc for fc in arcpy.ListFeatureClasses(feature_dataset=ds) if fc not in fcExclude]:
                    # append featureclass string to the fc list
                    _tmparray.append(fc)
    fcFilter = self.params[1].filter
    fcFilter.list = _tmparray&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Adding the .altered flag to that param will execute the list filter each time a new gdb is selected.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 15:12:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/parameter-b-selection-of-features-based-on/m-p/1345886#M69155</guid>
      <dc:creator>StaticK</dc:creator>
      <dc:date>2023-11-04T15:12:57Z</dc:date>
    </item>
  </channel>
</rss>

