2

as the header says, I do have a problem in getting my toolbox to function the way I want it to. In the following my parameter definition is shown, where from I would expect to get only feature classes of type point to be shown.

    def getParameterInfo(self):  
        #Define parameter definitions


        # Input Features parameter  
        in_workspace = arcpy.Parameter(  
            displayName="Input Workspace",  
            name="in_workspace",  
            datatype="DEWorkspace",  
            parameterType="Required",  
            direction="Input")  

        # FeatureClasses parameter
        in_fc = arcpy.Parameter(
            displayName="Input FC",
            name="classes",
            datatype="DEFeatureClass",
            parameterType="Required",
            direction="Input")
        in_fc.parameterDependencies = [in_workspace.name]
        in_fc.filter.list = ["POINT"]

        parameters = [in_workspace, in_fc]  

        return parameters

However, the resulting dropdown list shows all kind of content, e.g. point, line, and polygon feature classes. Even feature datasets are listed...

I got the suggestion to use GPFeatureLayer instead of DEFeatureClass, but as far as I understand Esri's resource center it looks to me as if GPFeatureLayer is in my case actually a detour to the datasets requested. When I tried GPFeatureLayer then there was no difference at all to the use of DEFeatureClass.

By my understanding, GPFeatureClass would be the way to go, FeatureDatasets should not appear in the list, and the filter set for the list should only populate the list of FeatureClasses with datasets of type point.

Does anybody of you can help me with this issue?

2

I had a go at this and confirm that the python toolbox is not behaving as expected. There is a relatively simple solution to this (although it may be unsatisfactory for your needs). Drop your workspace parameter and remove it from the parameterDependencies on the in_fc parameter. When you navigate to the workspace only Point datasets are shown.

1
  • Hi Duncan, thanks for the fast reply! Your suggestion brings indeed a solution to the issue. I just found another way to get the list while keeping the workspace, but hey - Why go the easy way, if there is a mor complicate one...? ;-) Oct 6 '14 at 14:00
1

Alright, instead of the expected list there is a rather full listing of the database content returned. Hence, I did a little handstand. ;-)

Here the changes to the parameter definition:

    # FeatureClasses parameter
    in_fc = arcpy.Parameter(
        displayName="Input FC",
        name="classes",
        datatype="String",
        parameterType="Required",
        direction="Input")

As suggested the parameterDependencies on the in_fc parameter have been removed. Then I introduced a global parameter within the script and went the way by foot...

    def updateParameters(self, parameters): #optional  
        if parameters[0].altered:
            global pnt_list    
            path = str(parameters[0].value)  
            pnt_list = []  
            lst_children = desc.children
            for item in lst_children:
                if item.dataType == 'FeatureClass' and item.shapeType == 'Point':
                    pnt_list.append(item.name)
            parameters[1].filter.list = pnt_list        

        return

It's a bit annoying but it essentially does what it should do. ;-)

3
  • So you are creating a "value list" of FeatureClass names?
    – Hornbydd
    Oct 6 '14 at 15:13
  • Yep, that's correct. I know that could have been done using ListFeatureClasses, however ESRI recommends the usage of Describe(), and I can imagine it is actually faster than the list-method. Oct 6 '14 at 15:23
  • Since I will need the whole path for each FC anyway I altered the code a bit and walk the Geodatabase instead of using the if-loop. I write names and the path into a dictionary and populate the value list with the keys in the dictionary. That should make it straight forward to use the finally selected FC and I get also all FCs within FeatureDatasets. Oct 6 '14 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.