<?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: Text String as input parameter in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613398#M20360</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;"%Ammonia%" I think this is correct.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not exactly. The value of your string variable (let's call it &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Compound&lt;/SPAN&gt;&lt;SPAN&gt;) should be set to &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Ammonia &lt;/SPAN&gt;&lt;SPAN&gt;(no quotes). Then you can refer to it elsewhere in the model as &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;%Compound%&lt;/SPAN&gt;&lt;SPAN&gt;, this will be replaced by the string &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Ammonia &lt;/SPAN&gt;&lt;SPAN&gt;at runtime. So a CV&amp;nbsp; expression &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"%Compound%" == "Ammonia"&lt;/SPAN&gt;&lt;SPAN&gt; (quotes included) becomes &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"Ammonia" == "Ammonia"&lt;/SPAN&gt;&lt;SPAN&gt; when CV is executed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our example, just worries about true and false. However, you can also use model variables in pathnames and other tool input expressions. You can see how CV is very handy to create strings that are ready to stick into a tool input parameter or a path. CV's output can be set to a multitude of data types; this make it possible to connect its output to a tool that expects that particular data type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way you set up &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;preconditions &lt;/SPAN&gt;&lt;SPAN&gt;is to grab the magic wand tool, click on a data element/variable you want set or created before a tool runs, then drag to the tool, let go, and pick "Precondition" from the list. Preconditions can also be set by right-clicking on a tool and going to the Precondition tab and adding an element there.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Apr 2013 20:31:59 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2013-04-02T20:31:59Z</dc:date>
    <item>
      <title>Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613391#M20353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a model that runs a two different processes and I would like to have which process to be run based on a user input.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have done this before by using a feature dataset allowing the user to select a point on the map to run model however, for this I would like to have the user select a text string from a list if possible (i.e. Ammonia, pH, VSS, COD). Then pass that text value to the model and have it run the desired process based on that selection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I am guessing that somehow I need to have the model take the value and test it and run the right process. But, I am not sure if this can be done or exactly how.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached a graphic of the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2013 12:59:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613391#M20353</guid>
      <dc:creator>EricStarn2</dc:creator>
      <dc:date>2013-04-01T12:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613392#M20354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Eric,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This can be accomplished through python.&amp;nbsp; You can easily export your model out to python in model builder by clicking Model &amp;gt; Export &amp;gt; To Python.&amp;nbsp; Then you would just need to update the python script.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
string = arcpy.GetParameterAsText(0)
if string == "Ammonia":
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;code&amp;gt;

if string == "pH":
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;code&amp;gt;

if string == "VSS":
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;code&amp;gt;

if string == "COD":
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;code&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You would want to replace &amp;lt;code&amp;gt; with the exported python code from model builder that you would like executed when the user selects the string value.&amp;nbsp; After you are finished updating the python file, you can add the script back to your toolbox (right-click on your toolbox &amp;gt; Add &amp;gt; Script).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once the script is added, right-click on the script &amp;gt; Properties &amp;gt; Parameters tab.&amp;nbsp; Set up a parameter with a data type of 'String' and set the 'Filter' property to 'Value List'.&amp;nbsp; You can then add the required string values:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]23114[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once this is set up, when user's execute the script they will be presented with a drop down of values:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]23115[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:14:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613392#M20354</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T02:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613393#M20355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks that helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However maybe just a little more help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I export the model into python and it is group a little different then I expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So if you can help me in where I need to put your suggested text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I attached the file &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2013 15:52:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613393#M20355</guid>
      <dc:creator>EricStarn2</dc:creator>
      <dc:date>2013-04-01T15:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613394#M20356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Eric, Python scripting makes sense when things get complicated, epecially if you need more control over error messages and tool validation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, there are several approaches within Model Builder, some involving a script tool, some just using Calculate Value. Here's my favorite method, using the "model-only" Calculate Value tool, to calculate a Boolean (true/false) value and connecting its output as preconditions to the processing chains. In this example, I use the Merge Branch tool to provide the same output whether I use one option or the other.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]23118[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I highly recommend this set of blog posts:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2011/06/06/modelbuilderifthenelse1/"&gt;ArcGIS blog: if you are stuck at "if"&amp;nbsp; (5 parts)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using Calculate Value, filters, and preconditions, you can build some pretty sophisticated tools within ModelBuilder.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2013 16:38:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613394#M20356</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-04-01T16:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613395#M20357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Curtis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That looks like just what I am looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I read through the blog but am still unsure about this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using your attachment as reference I can see you take a string variable and check to see what the string is using the "Calculate Value" tool and then set the data type to Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But I am not quite sure what to put in the code block or expression field and string variable a precondition to the "Calculate Value" tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2013 18:24:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613395#M20357</guid>
      <dc:creator>EricStarn2</dc:creator>
      <dc:date>2013-04-01T18:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613396#M20358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Using your attachment as reference I can see you take a string variable and check to see what the string is using the "Calculate Value" (CV) tool and then set the data type to Boolean. But I am not quite sure what to put in the code block or expression field and string variable a precondition to the "Calculate Value" tool?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the CV tool, you fill in the expression with the one I put in the label:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;"%String%" == "A"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Leave the CV code block blank. If the test were complicated, you would put a function in the code block. but in this case you do not need it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt; is the name of a data element in your model. The value of String gets put there before Python sees it, so it evaluates at run time to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;"A" == "A"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which returns 1 which is returned as True if you set the output type to Boolean.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then grab the magic wand tool and connect the output of Calculate Value to the first tool in a process chain you want to run when "%String%" == "A". Select "Precondition" from the context menu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do this the same with the other one ("%String%" == "B"). Set the output as a precondition to processing chain B. If this evaulates to false ("B" == "A" - is false), the second processing chain will not run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Neat, isn't it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2013 19:22:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613396#M20358</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-04-01T19:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613397#M20359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Curtis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is perfect&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have now built most of the model&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but I do still need maybe a little more clarification on the data element for the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I created a String Variable and then set it to "%Ammonia%" I think this is correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then what is the correct way to connect it to the CV tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Environments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Precondition&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please let me know if I am way off track&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks immensely for your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2013 16:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613397#M20359</guid>
      <dc:creator>EricStarn2</dc:creator>
      <dc:date>2013-04-02T16:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Text String as input parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613398#M20360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;"%Ammonia%" I think this is correct.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not exactly. The value of your string variable (let's call it &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Compound&lt;/SPAN&gt;&lt;SPAN&gt;) should be set to &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Ammonia &lt;/SPAN&gt;&lt;SPAN&gt;(no quotes). Then you can refer to it elsewhere in the model as &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;%Compound%&lt;/SPAN&gt;&lt;SPAN&gt;, this will be replaced by the string &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Ammonia &lt;/SPAN&gt;&lt;SPAN&gt;at runtime. So a CV&amp;nbsp; expression &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"%Compound%" == "Ammonia"&lt;/SPAN&gt;&lt;SPAN&gt; (quotes included) becomes &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"Ammonia" == "Ammonia"&lt;/SPAN&gt;&lt;SPAN&gt; when CV is executed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our example, just worries about true and false. However, you can also use model variables in pathnames and other tool input expressions. You can see how CV is very handy to create strings that are ready to stick into a tool input parameter or a path. CV's output can be set to a multitude of data types; this make it possible to connect its output to a tool that expects that particular data type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way you set up &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;preconditions &lt;/SPAN&gt;&lt;SPAN&gt;is to grab the magic wand tool, click on a data element/variable you want set or created before a tool runs, then drag to the tool, let go, and pick "Precondition" from the list. Preconditions can also be set by right-clicking on a tool and going to the Precondition tab and adding an element there.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2013 20:31:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/text-string-as-input-parameter/m-p/613398#M20360</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-04-02T20:31:59Z</dc:date>
    </item>
  </channel>
</rss>

