<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to set a variable from a list in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65590#M2322</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;could anyone just point me in the right direction on this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is the code that the selection of the list would get, it runs fine with the user typing in the selection&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;## Import standard modules
import sys, os

## Set the product code
import arcinfo

## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env

## Sets the MXD file to the current ArcMap MXD, if run out of ArcMap use the full path to the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")

## Set Data Frames for the layer to select from
MDF = arcpy.mapping.ListDataFrames(IMXD, "Main Map")[0]

## Set the Index layers
ILyr = arcpy.mapping.ListLayers(IMXD,"PLSS")[0]

## Set the Section, Township and Range
STR = arcpy.GetParameterAsText(0)
# STR = '5-15-33'

## Create the SQL Query for the sheet number
SheetQry = r"SecTwnRng = '%s'"%(STR)

## Select the Aerial
try:
&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
&amp;nbsp;&amp;nbsp; Num = str(arcpy.GetCount_management(ILyr))
&amp;nbsp;&amp;nbsp; if Num == "0":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("!! NO CORRESPONDING PLSS AREA EXISTS FOR THIS REQUEST !!")
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Get Extent of Selected Sheet
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IExt = ILyr.getSelectedExtent()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Pan to selected extent
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MDF.panToExtent(IExt)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the seperated STR text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SECTWNRNG = STR.split("-")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SEC = SECTWNRNG[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TWN = SECTWNRNG[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RNG = SECTWNRNG[2]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Set the S-T-R Text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if SheetNum.text == "SEC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TWN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RNG":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SheetNum.text = r"%s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %s"%(SEC, TWN, RNG)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Refresh data farame
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Please refresh the map on completion")
except:
&amp;nbsp;&amp;nbsp; arcpy.GetMessages()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:32:03 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-10T22:32:03Z</dc:date>
    <item>
      <title>how to set a variable from a list</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65589#M2321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i want to make a model that the user can select a choice from a list in the dialog and that choice will be passed as a variable to a python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the model has a list of choices that show up as parameters but the model runs for all of them and not just the one selected&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;also is there a way to use a table or file to create the selection list for a variable in model builder instead of typing each choice itn the add variable box?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2011 14:54:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65589#M2321</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-04-13T14:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to set a variable from a list</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65590#M2322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;could anyone just point me in the right direction on this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is the code that the selection of the list would get, it runs fine with the user typing in the selection&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;## Import standard modules
import sys, os

## Set the product code
import arcinfo

## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env

## Sets the MXD file to the current ArcMap MXD, if run out of ArcMap use the full path to the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")

## Set Data Frames for the layer to select from
MDF = arcpy.mapping.ListDataFrames(IMXD, "Main Map")[0]

## Set the Index layers
ILyr = arcpy.mapping.ListLayers(IMXD,"PLSS")[0]

## Set the Section, Township and Range
STR = arcpy.GetParameterAsText(0)
# STR = '5-15-33'

## Create the SQL Query for the sheet number
SheetQry = r"SecTwnRng = '%s'"%(STR)

## Select the Aerial
try:
&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
&amp;nbsp;&amp;nbsp; Num = str(arcpy.GetCount_management(ILyr))
&amp;nbsp;&amp;nbsp; if Num == "0":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("!! NO CORRESPONDING PLSS AREA EXISTS FOR THIS REQUEST !!")
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Get Extent of Selected Sheet
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IExt = ILyr.getSelectedExtent()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Pan to selected extent
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MDF.panToExtent(IExt)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the seperated STR text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SECTWNRNG = STR.split("-")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SEC = SECTWNRNG[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TWN = SECTWNRNG[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RNG = SECTWNRNG[2]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Set the S-T-R Text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if SheetNum.text == "SEC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TWN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RNG":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SheetNum.text = r"%s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %s"%(SEC, TWN, RNG)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Refresh data farame
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Please refresh the map on completion")
except:
&amp;nbsp;&amp;nbsp; arcpy.GetMessages()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:32:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65590#M2322</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T22:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to set a variable from a list</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65591#M2323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I could be wrong, and I'd be interested to know a model builder solution, but the only way I can think of to get a selection from a list is with ArcObjects. Once you have that selection, you could call the rest of your python script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2011 17:37:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-set-a-variable-from-a-list/m-p/65591#M2323</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-04-15T17:37:32Z</dc:date>
    </item>
  </channel>
</rss>

