flederfauz

How to set user supplied Parameters for Fields when creating a Tool.

Discussion created by flederfauz on May 16, 2011
Latest reply on May 18, 2011 by flederfauz
Hi!

I just wrote some code and it works fine so far. Now I want to bring it into a toolbox so people have to choose, the folder where the files are, 2 feature layers and one field for each featurelayer.
I imported the python Script and set the Parameter in the AddScript dialogboxas follows:
Display Name          Data Type
MyFolder                 Folder
FeatureClass1          FeatureClass  
FeatureClass2          FeatureClass
FieldFeatureClass1   Field
FieldFeatureClass2   Field

SO if I execute the tool and entered folder and featureclasses the dropdowntables for "Field" are both empty. What do I have to change?

import arcpy
from arcpy import env
import os
def __init__(self):
    Folder=self.params[0]
    import arcpy
from arcpy import env
import os
def __init__(self):
   MyFolder=self.params[0]
   FeatureClass1=self.params[1]
   FeatureClass2=self.params[2]
   self.params[3].parameterDependencies = [1]
   FeatureClass1Field=self.params[3].parameterDependencies = [1]
   FeatureClass1Field=self.params[3]
   FeatureClass2Field=self.params[4].parameterDependencies = [2]
   FeatureClass2Field=self.params[4]

Outcomes