<?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 can I set my tool boolean parameter to true in my arcpy script? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140172#M63646</link>
    <description>&lt;P&gt;&lt;SPAN&gt;(CreatePPTFieldID = "True") is an assignment statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(CreatePPTFieldID == "True") is a condition statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;throw in a print statement to make sure it is returning a text string ("True" ) and not a boolean ( True )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;exit() isn't needed&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Feb 2022 04:40:35 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-02-03T04:40:35Z</dc:date>
    <item>
      <title>How can I set my tool boolean parameter to true in my arcpy script?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140154#M63645</link>
      <description>&lt;P&gt;I have set one my ArcGIS Pro tool's parameter as optional to auto populate a field ID if the field ID is missing. However, when I tried to populate the field ID, it does not work. How do I set my boolean parameter to true in my script to populated the required ID field?&amp;nbsp; (On a side note, the "with arcpy.da.SearchCursor" block is meant to search in the first row of the column, OBJECTID to determine if it is zero; if the condition is true, then it will calculate the field ID with "!OBJECTID!+1" and if not, it will use "!OBJECTID!", because the ID needs to start with 1. Is there a better way of writing this part of the script? Not my main question, but just curious for other suggestion. Thanks everyone! )&lt;/P&gt;&lt;P&gt;CreatePPTFieldID = arcpy.GetParameterAsText(8)&lt;/P&gt;&lt;P&gt;#Creating the field ID&lt;BR /&gt;if (CreatePPTFieldID = "True"):&lt;BR /&gt;&amp;nbsp; &amp;nbsp;arcpy.management.AddField(inpourpoint,"ID","Long")&lt;BR /&gt;&amp;nbsp; &amp;nbsp;with arcpy.da.SearchCursor(inpourpoint, 'OBJECTID') as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (row[0]==0):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.CalculateField_management(inpourpoint,"ID","!OBJECTID!+1")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;arcpy.CalculateField_management(inpourpoint,"ID","!OBJECTID!")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;exit()&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 01:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140154#M63645</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2022-02-03T01:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set my tool boolean parameter to true in my arcpy script?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140172#M63646</link>
      <description>&lt;P&gt;&lt;SPAN&gt;(CreatePPTFieldID = "True") is an assignment statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(CreatePPTFieldID == "True") is a condition statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;throw in a print statement to make sure it is returning a text string ("True" ) and not a boolean ( True )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;exit() isn't needed&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 04:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140172#M63646</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-03T04:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set my tool boolean parameter to true in my arcpy script?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140188#M63647</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;I think the respond is a few lines before. tzz_12 when you are getting values from toolbox, you can get the variables as TEXT or as 'they are'. so try instead&lt;/P&gt;&lt;P&gt;CreatePPTFieldID = arcpy.GetParameterAsText(8)&lt;/P&gt;&lt;P&gt;CreatePPTFieldID = arcpy.GetParameter(8)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 06:33:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-my-tool-boolean-parameter-to-true-in/m-p/1140188#M63647</guid>
      <dc:creator>Tomasz_Tarchalski</dc:creator>
      <dc:date>2022-02-03T06:33:08Z</dc:date>
    </item>
  </channel>
</rss>

