In the ArcGIS Pro toolbox, what would be the parameter to set so that we can add a drop-down menu to choose the map frame name?
Vince
20.5k16 gold badges49 silver badges65 bronze badges
-
Is this for a Python script tool, a Python Toolbox tool or perhaps a Model tool?PolyGeo– PolyGeo ♦2023年02月07日 10:55:40 +00:00Commented Feb 7, 2023 at 10:55
1 Answer 1
Set the params index number to the parameter for the dropdown. The zero below is for the first parameter.
def initializeParameters(self):
# Customize parameter properties.
# This gets called when the tool is opened.
aprx = arcpy.mp.ArcGISProject("CURRENT")
map_list = [mf.name for mf in aprx.listMaps()]
self.params[0].filter.list = map_list
return
For map frame elements. The below assumes one Layout in the APRX.
def initializeParameters(self):
# Customize parameter properties.
# This gets called when the tool is opened.
aprx = arcpy.mp.ArcGISProject("CURRENT")
lyt = aprx.listLayouts()[0]
mapf_list = [mf.name for mf in lyt.listElements("MAPFRAME_ELEMENT")]
self.params[0].filter.list = mapf_list
return
answered Feb 7, 2023 at 10:45
lang-py