<?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: Using Part of File Name as Parameter in ModelBuilder Questions</title>
    <link>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874879#M2796</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the info Duncan!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sent from my iPhone&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Oct 2016 17:06:04 GMT</pubDate>
    <dc:creator>ChrisHolmes</dc:creator>
    <dc:date>2016-10-20T17:06:04Z</dc:date>
    <item>
      <title>Using Part of File Name as Parameter</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874877#M2794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have a parameter named LocNo. It is used as a parameter in a model or two. Currently I have the user manually enter the LocNo value when the model starts. LocNo also happens to be the first 12 characters in the name of the mxd file.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/247291_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way that I can grab the first 12 characters and use them as the value passed into the parameter?&lt;/P&gt;&lt;P&gt;For example here is a part of the model that shows how the LocNo is used:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/247292_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;If I can grab those first 12 characters from the filename and insert that into the parameter in the model I'm sure it would save on having some human error introduced.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:52:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874877#M2794</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2016-10-18T13:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Part of File Name as Parameter</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874878#M2795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use a combination of &lt;EM&gt;Parse Path&lt;/EM&gt; and &lt;EM&gt;Calculate value&lt;/EM&gt; tool, which are&amp;nbsp;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/a-quick-tour-of-using-model-only-tools.htm"&gt;model only tools&lt;/A&gt;&amp;nbsp;so only accessible from within model builder. The input would have to be a variable of type ArcMap Document and the model would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="248602" alt="Model" class="image-1 jive-image j-img-centered j-img-original" src="https://community.esri.com/legacyfs/online/248602_Untitled.png" style="display: block; margin-left: auto; margin-right: auto;" /&gt;&lt;/P&gt;&lt;P&gt;In the example above I use the python expression &lt;STRONG&gt;"%Value%"[:5]&lt;/STRONG&gt; to return the first 5 characters of the mxd name. The user would have to select an existing mxd, even if it is the one they already have open. Also note that the output of Parse Path, value, is a precondition to the Calculate value tool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2016 15:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874878#M2795</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2016-10-20T15:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Part of File Name as Parameter</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874879#M2796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the info Duncan!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sent from my iPhone&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2016 17:06:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874879#M2796</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2016-10-20T17:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using Part of File Name as Parameter</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874880#M2797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thought I'd provide a quick update. I've moved this functionality over to the following python script. Works well.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
locPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;basename&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;filePath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
LOC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; locPath&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;12&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
returnLOC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; LOC&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;upper&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; returnLOC&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:58:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/using-part-of-file-name-as-parameter/m-p/874880#M2797</guid>
      <dc:creator>ChrisHolmes</dc:creator>
      <dc:date>2021-12-12T10:58:07Z</dc:date>
    </item>
  </channel>
</rss>

