Pass attributes to arcpy.GetParameterAsText

07-07-2020 08:31 AM
Regular Contributor

Working with Arcmap 10.6 and ArcToolbox script, I would like to select polygons and pass the attributes of a field of those selected polygons to arcpy.GetParameterAsText , I would then pass the arcpy.GetParameterAsText to update the TEXT ELEMENT of arcpy.mapping.ListLayoutElements to something like R2875103700_R2875103600_R2875300000_R2829301100. Is this possible if so how?

0 Kudos
1 Reply
Regular Contributor

I was able to figure it out and it wasn't as complicated as I thought.

if int(arcpy.GetCount_management("Parcels").getOutput(0)) > 0:

        arcpy.Select_analysis("Parcels", "SelPar")
unique_values = set(row[0] for row in arcpy.da.SearchCursor("SelPar", "Field"))

format1 = ("_".join(unique_values))

Name = format1
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
    if elm.text == "Par Text":
        elm.text = Name