<?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 ArcGIS Pro Python Toolbox: Update parameters not working as expected in Model Builder in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-python-toolbox-update-parameters-not/m-p/524130#M23069</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a tool in Python toolbox, it has two parameters. &lt;BR /&gt;If I run this tool from toolbox, it is working fine.&lt;BR /&gt;If I add this tool to model builder and run the model, it not working as expected.&lt;/P&gt;&lt;P&gt;Problem is that if I update Input Value 1, then Input Value 2 is updated as expected. But if I update Input Value 2, then the value of Input Value 1 is not updated as expected.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;class Toolbox(object):&lt;BR /&gt; def __init__(self):&lt;BR /&gt; """Define the toolbox (the name of the toolbox is the name of the&lt;BR /&gt; .pyt file)."""&lt;BR /&gt; self.label = "Toolbox"&lt;BR /&gt; self.alias = ""&lt;/P&gt;&lt;P&gt;# List of tool classes associated with this toolbox&lt;BR /&gt; self.tools = [Tool]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;class Tool(object):&lt;BR /&gt; def __init__(self):&lt;BR /&gt; """Define the tool (tool name is the name of the class)."""&lt;BR /&gt; self.label = "Tool"&lt;BR /&gt; self.description = ""&lt;BR /&gt; self.canRunInBackground = False&lt;/P&gt;&lt;P&gt;def getParameterInfo(self):&lt;BR /&gt; """Define parameter definitions"""&lt;BR /&gt; params = []&lt;BR /&gt; param1 = arcpy.Parameter(&lt;BR /&gt; displayName="Input Value 1", &lt;BR /&gt; name="param1",&lt;BR /&gt; datatype="GPDouble", parameterType="Required", direction="Input")&lt;BR /&gt; param1.value = 1.0&lt;/P&gt;&lt;P&gt;param2 = arcpy.Parameter(&lt;BR /&gt; displayName="Input Value 2", &lt;BR /&gt; name="param2",&lt;BR /&gt; datatype="GPDouble", parameterType="Optional", direction="Input")&lt;BR /&gt; &lt;BR /&gt; params = [param1, param2]&lt;BR /&gt; return params&lt;/P&gt;&lt;P&gt;def isLicensed(self):&lt;BR /&gt; """Set whether tool is licensed to execute."""&lt;BR /&gt; return True&lt;/P&gt;&lt;P&gt;def updateParameters(self, parameters):&lt;BR /&gt; """Modify the values and properties of parameters before internal&lt;BR /&gt; validation is performed. This method is called whenever a parameter&lt;BR /&gt; has been changed."""&lt;/P&gt;&lt;P&gt;if (parameters[0].altered and not parameters[0].hasBeenValidated):&lt;BR /&gt; parameters[1].value = parameters[0].value * 4&lt;/P&gt;&lt;P&gt;if (parameters[1].altered and not parameters[1].hasBeenValidated):&lt;BR /&gt; parameters[0].value = parameters[1].value / 4&lt;BR /&gt; &lt;BR /&gt; return&lt;/P&gt;&lt;P&gt;def updateMessages(self, parameters):&lt;BR /&gt; """Modify the messages created by internal validation for each tool&lt;BR /&gt; parameter. This method is called after internal validation."""&lt;BR /&gt; return&lt;/P&gt;&lt;P&gt;def execute(self, parameters, messages):&lt;BR /&gt; """The source code of the tool."""&lt;BR /&gt; return&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me to fix this issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Aug 2020 18:34:28 GMT</pubDate>
    <dc:creator>SurendraPinjala</dc:creator>
    <dc:date>2020-08-20T18:34:28Z</dc:date>
    <item>
      <title>ArcGIS Pro Python Toolbox: Update parameters not working as expected in Model Builder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-python-toolbox-update-parameters-not/m-p/524130#M23069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a tool in Python toolbox, it has two parameters. &lt;BR /&gt;If I run this tool from toolbox, it is working fine.&lt;BR /&gt;If I add this tool to model builder and run the model, it not working as expected.&lt;/P&gt;&lt;P&gt;Problem is that if I update Input Value 1, then Input Value 2 is updated as expected. But if I update Input Value 2, then the value of Input Value 1 is not updated as expected.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;class Toolbox(object):&lt;BR /&gt; def __init__(self):&lt;BR /&gt; """Define the toolbox (the name of the toolbox is the name of the&lt;BR /&gt; .pyt file)."""&lt;BR /&gt; self.label = "Toolbox"&lt;BR /&gt; self.alias = ""&lt;/P&gt;&lt;P&gt;# List of tool classes associated with this toolbox&lt;BR /&gt; self.tools = [Tool]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;class Tool(object):&lt;BR /&gt; def __init__(self):&lt;BR /&gt; """Define the tool (tool name is the name of the class)."""&lt;BR /&gt; self.label = "Tool"&lt;BR /&gt; self.description = ""&lt;BR /&gt; self.canRunInBackground = False&lt;/P&gt;&lt;P&gt;def getParameterInfo(self):&lt;BR /&gt; """Define parameter definitions"""&lt;BR /&gt; params = []&lt;BR /&gt; param1 = arcpy.Parameter(&lt;BR /&gt; displayName="Input Value 1", &lt;BR /&gt; name="param1",&lt;BR /&gt; datatype="GPDouble", parameterType="Required", direction="Input")&lt;BR /&gt; param1.value = 1.0&lt;/P&gt;&lt;P&gt;param2 = arcpy.Parameter(&lt;BR /&gt; displayName="Input Value 2", &lt;BR /&gt; name="param2",&lt;BR /&gt; datatype="GPDouble", parameterType="Optional", direction="Input")&lt;BR /&gt; &lt;BR /&gt; params = [param1, param2]&lt;BR /&gt; return params&lt;/P&gt;&lt;P&gt;def isLicensed(self):&lt;BR /&gt; """Set whether tool is licensed to execute."""&lt;BR /&gt; return True&lt;/P&gt;&lt;P&gt;def updateParameters(self, parameters):&lt;BR /&gt; """Modify the values and properties of parameters before internal&lt;BR /&gt; validation is performed. This method is called whenever a parameter&lt;BR /&gt; has been changed."""&lt;/P&gt;&lt;P&gt;if (parameters[0].altered and not parameters[0].hasBeenValidated):&lt;BR /&gt; parameters[1].value = parameters[0].value * 4&lt;/P&gt;&lt;P&gt;if (parameters[1].altered and not parameters[1].hasBeenValidated):&lt;BR /&gt; parameters[0].value = parameters[1].value / 4&lt;BR /&gt; &lt;BR /&gt; return&lt;/P&gt;&lt;P&gt;def updateMessages(self, parameters):&lt;BR /&gt; """Modify the messages created by internal validation for each tool&lt;BR /&gt; parameter. This method is called after internal validation."""&lt;BR /&gt; return&lt;/P&gt;&lt;P&gt;def execute(self, parameters, messages):&lt;BR /&gt; """The source code of the tool."""&lt;BR /&gt; return&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me to fix this issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2020 18:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-python-toolbox-update-parameters-not/m-p/524130#M23069</guid>
      <dc:creator>SurendraPinjala</dc:creator>
      <dc:date>2020-08-20T18:34:28Z</dc:date>
    </item>
  </channel>
</rss>

