<?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 do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399347#M17736</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You enter the value list manually&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image" height="292" src="https://community.esri.com/legacyfs/online/456800_tool_valuelist.png" width="691" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Aug 2019 09:00:01 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-08-12T09:00:01Z</dc:date>
    <item>
      <title>how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399344#M17733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to build a tool based on script in arcgis pro (the tool makes changes to a field with calculate field based on a list of variables). how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ?&lt;/P&gt;&lt;P&gt;my problem is that it does not recognize my list: "NameError: name 'surv_list' is not defined"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is my script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.workspace = r"C:\GIS\project_prebuild.gdb"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Exmaple fot text input to run tool in python:&lt;BR /&gt;##surv_list = (('FT18-17',235,300),('FT18-17',410,432),('FT18-15',101,130),('FT18-13',101,140))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;surv_list = arcpy.GetParameterAsText(0)&lt;BR /&gt; record_list = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;codeblock = ("""def update_status(line,point,surv_list,record_list):&lt;BR /&gt; if len(surv_list[0])==3:&lt;BR /&gt; for x in surv_list:&lt;BR /&gt; if line == x[0] and point &amp;gt;= x[1] and point &amp;lt;= x[2]:&lt;BR /&gt; return 1&lt;BR /&gt; elif line == surv_list[0] and point &amp;gt;= surv_list[1] and point &amp;lt;= surv_list[2]:&lt;BR /&gt; return 1&lt;BR /&gt; &lt;BR /&gt; if len(record_list[0])==3:&lt;BR /&gt; for y in record_list:&lt;BR /&gt; if line == y[0] and point &amp;gt;= y[1] and point &amp;lt;= y[2]:&lt;BR /&gt; return 2&lt;BR /&gt; elif line == record_list[0] and point &amp;gt;= record_list[1] and point &amp;lt;= record_list[2]:&lt;BR /&gt; return 2""")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management("REC_Preplot_25m","Status","update_status(!LineNumber!,!Station!,surv_list,record_list)","PYTHON3",codeblock)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Aug 2019 06:25:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399344#M17733</guid>
      <dc:creator>NadavBronshtein</dc:creator>
      <dc:date>2019-08-11T06:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399345#M17734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use a custom python tool and attach it to a toolbox.&amp;nbsp; Get your parameters first then use them in the code block&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/adding-a-script-tool.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/adding-a-script-tool.htm"&gt;Adding a script tool—Geoprocessing and Python | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use your surv_list as a "value list" under the "filter" option.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/setting-script-tool-parameters.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/setting-script-tool-parameters.htm"&gt;Setting script tool parameters—Geoprocessing and Python | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be a Text parameter, direction "input"&lt;/P&gt;&lt;P&gt;The same for your other list.&lt;/P&gt;&lt;P&gt;The inputs can then be fed into your code block.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Aug 2019 08:35:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399345#M17734</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-08-11T08:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399346#M17735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for replying. I did all the thing but didn't understand the "use of&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;surv_list as a "value list" under the "filter" option". my&amp;nbsp;attempt is to enter a random list to the tool in the form of:(name,from_point,to_point), or list of lists: (&lt;SPAN&gt;(name, from_point, to_point),&lt;/SPAN&gt;&lt;SPAN&gt;(name2, from_point2, to_point2)) and than use these 3 variable of each list in the code block to return a value if i have a match.&lt;BR /&gt;i might have other problems with my code but for start, i cant get the list i enter in the tool to be identified in the code block. any suggestions ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;Thanks in advanced&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/456799_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2019 08:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399346#M17735</guid>
      <dc:creator>NadavBronshtein</dc:creator>
      <dc:date>2019-08-12T08:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399347#M17736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You enter the value list manually&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image" height="292" src="https://community.esri.com/legacyfs/online/456800_tool_valuelist.png" width="691" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2019 09:00:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-use-a-list-inserted-with-arcpy/m-p/399347#M17736</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-08-12T09:00:01Z</dc:date>
    </item>
  </channel>
</rss>

