<?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 Network Attribute Data Types in the GUI in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98336#M990</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to make a GUI for a tool that takes the network "Impedance Value" as a value that is 'obtained' from the inputted Network Dataset. That is, I would like to have the "Impedance Value" field in the GUI check what cost attributes the given input network has available, and restrict the options from a drop-down to only those cost attributes. This exact actions is available, for instance, in the "Make OD Cost Matrix Layer" tool,"Make Route Layer" tool and other NA tools. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am unable, however, to figure out what the input parameter field 'data type' needs to be for that to happen. There is no 'Network Attribute' data type offered in the tool properties dialog box. Unfortunately cannot see what 'data type' other NA tools use for the "Impedance Value" field. Help!&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;Andres&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Aug 2011 12:39:29 GMT</pubDate>
    <dc:creator>AndresSevtsuk</dc:creator>
    <dc:date>2011-08-30T12:39:29Z</dc:date>
    <item>
      <title>Network Attribute Data Types in the GUI</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98336#M990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to make a GUI for a tool that takes the network "Impedance Value" as a value that is 'obtained' from the inputted Network Dataset. That is, I would like to have the "Impedance Value" field in the GUI check what cost attributes the given input network has available, and restrict the options from a drop-down to only those cost attributes. This exact actions is available, for instance, in the "Make OD Cost Matrix Layer" tool,"Make Route Layer" tool and other NA tools. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am unable, however, to figure out what the input parameter field 'data type' needs to be for that to happen. There is no 'Network Attribute' data type offered in the tool properties dialog box. Unfortunately cannot see what 'data type' other NA tools use for the "Impedance Value" field. Help!&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;Andres&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 12:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98336#M990</guid>
      <dc:creator>AndresSevtsuk</dc:creator>
      <dc:date>2011-08-30T12:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Network Attribute Data Types in the GUI</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98337#M991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Andres,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; What you want to accomplish is possible in ArcGIS 10 (and even 9.3) but with some additional python code. A script tool�??s GUI can be further programmed using a ToolValidator class. This class can perform actions such as populating values of a parameter based on value from another parameter or enabling/disabling a parameter based on other parameters. More info about the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Customizing_script_tool_behavior/00150000000t000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;ToolValidator class is available in the help&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There was also a recent blog post on the geoprocessing blog explaining &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/Dev/blogs/geoprocessing/archive/2011/08/25/Generating-a-choice-list-from-a-field-.aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;how to use ToolValidator class&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For your case, In your script tool, You need to define&amp;nbsp; a network dataset parameter of type network dataset layer and a second parameter called Impedance of type string. Then you can use the attached tool validator code to automatically populate the values for Impedance value parameter based on the network dataset. I am attaching the toolbox containing this sample code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;class ToolValidator:
&amp;nbsp; """Class for validating a tool's parameter values and controlling
&amp;nbsp; the behavior of the tool's dialog."""
&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Setup arcpy and the list of tool parameters."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy as ARC
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.arcpy = ARC
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.paramsIndex = {'networkDataset':0,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'impedance': 1}
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params = arcpy.GetParameterInfo()&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get the parameter objects that will be modified
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.networkParam = self.params[self.paramsIndex['networkDataset']]
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.impedanceParam = self.params[self.paramsIndex['impedance']]

&amp;nbsp; def initializeParameters(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Refine the properties of a tool's parameters.&amp;nbsp; This method is
&amp;nbsp;&amp;nbsp;&amp;nbsp; called when the tool is opened."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&amp;nbsp; def updateParameters(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the values and properties of parameters before internal
&amp;nbsp;&amp;nbsp;&amp;nbsp; validation is performed.&amp;nbsp; This method is called whenever a parmater
&amp;nbsp;&amp;nbsp;&amp;nbsp; has been changed."""&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if self.networkParam.altered:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if self.networkParam.value and not self.networkParam.hasBeenValidated:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Check if the NDS exits
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.getNetworkProps(self.networkParam.value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetNetworkProps()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetNetworkProps()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&amp;nbsp; def updateMessages(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&amp;nbsp; 
&amp;nbsp; def getNetworkProps(self,network):
&amp;nbsp;&amp;nbsp;&amp;nbsp; '''Update the parameter values based on th network dataset'''&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = self.arcpy.Describe(network)
&amp;nbsp;&amp;nbsp;&amp;nbsp; defaultCostAttr = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; costAttributes = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Build a list of cost attributes and get the default cost attribute
&amp;nbsp;&amp;nbsp;&amp;nbsp; attributes = desc.attributes
&amp;nbsp;&amp;nbsp;&amp;nbsp; for attribute in attributes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usageType = attribute.usageType
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = attribute.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useByDefault = attribute.useByDefault 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if usageType == "Cost":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Check if the cost attribute has to be used by default.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if useByDefault:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defaultCostAttr = name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; costAttributes.append(name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the lists for cost attribute&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.impedanceParam.filter.list = costAttributes&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the default value for the cost attribute 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not self.impedanceParam.altered:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if defaultCostAttr == "" and costAttributes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #if there is no default use the first one in the list
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defaultCostAttr = costAttributes[0] 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.impedanceParam.value = defaultCostAttr
&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; def resetNetworkProps(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Resets the network dataset derived parameters to nothing"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.impedanceParam.filter.list = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.impedanceParam.value = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Deelesh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:08:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98337#M991</guid>
      <dc:creator>DeeleshMandloi</dc:creator>
      <dc:date>2021-12-11T06:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Network Attribute Data Types in the GUI</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98338#M992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Deelesh, it works nicely! In case others wonder, the only thing to change in the validator code are the input order numbers of the Network Dataset and Impedance Attribute (if you have them in a different order in your tool). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;self.paramsIndex = {'networkDataset':1, 'impedance': 9}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andres&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 13:10:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/network-attribute-data-types-in-the-gui/m-p/98338#M992</guid>
      <dc:creator>AndresSevtsuk</dc:creator>
      <dc:date>2011-08-31T13:10:05Z</dc:date>
    </item>
  </channel>
</rss>

