amyrsmith

Select Input Parameters from Dropdown List Showing Current Map Layers

Discussion created by amyrsmith on May 10, 2011
Latest reply on May 10, 2011 by amyrsmith
Hello!

I'm very new to creating script tools, and I recently started working with the Tool Validator. I'd like the users of my script tool to be able to select their input parameters from a dropdown list showing current map layers that match the input type (for example, if the input is specified as the type "Feature Class", a list of feature classes in the current map document would appear as options in a dropdown list). Most of the ArcGIS tools automatically do this.

Although it doesn't work, this is what I have come up with so far (input 1 is a Feature Class, and input 2 is a Raster):

def initializeParameters(self):
    
    mxd = arcpy.mapping.MapDocument("CURRENT")
    featureLayerList = []
    rasterLayerList = []
    for lyr in arcpy.mapping.ListLayers(mxd):
      if lyr.isFeatureLayer == True:
        featureLayerList.append(lyr.name)
      elif lyr.isRasterLayer == True:
        rasterLayerList.append(lyr.name)
    self.params[1].filter.list = featureLayerList
    self.params[2].filter.list = rasterLayerList

    return


I would greatly appreciate any advice!

Ride the lightning,

Amy

---
www.wolfmapper.com

Outcomes