Frequently asked question

How to migrate network dataset evaluators from VBScript to Python?

Last Published: December 18, 2024

Answer

Network dataset Field Script and Element Script evaluators using VBScript have been deprecated for several releases of ArcGIS Pro, and support for VBScript-based evaluators will be removed in the ArcGIS Pro 3.5 release. This article explains what still works and what does not work starting in ArcGIS Pro 3.5 and how to update VBScript-based evaluators to Python.

Background

Each network dataset attribute, such as a cost attribute or restriction, is configured with evaluators, which tell the network how to calculate a value for the attribute for each network edge, junction, or turn. For example, an evaluator for a cost attribute performs some calculation to determine how much it costs (usually in time or distance) to travel down a specific street.

The Field Script evaluator performs this calculation by checking the value of one or more fields in a network dataset source feature class. The Element Script evaluator performs this calculation based on user code that can reference other network attributes, parameters, and properties.

Historically, both Field Script and Element Script evaluators could be written in either VBScript or Python. Starting with the ArcGIS Pro 3.4 release, it is no longer possible to edit VBScript-based evaluators and must be changed to Python before making any changes. Starting in the ArcGIS Pro 3.5 release, certain functionalities will no longer work for network datasets with evaluators coded in VBScript.

What will not work

Starting from ArcGIS Pro 3.5, the following functionalities cease to work:

  • Building a network with VBScript-based Field Script or Element Script evaluators.
  • Dissolving a network with VBScript-based Field Script or Element Script evaluators.
  • Packaging a network with VBScript-based Field Script or Element Script evaluators.
  • Creating a network dataset template from a network with VBScript-based Field Script or Element Script evaluators.
  • Creating a new network dataset from an existing network dataset template created from a network with any VBScript-based Field Script or Element Script evaluators.
  • Solving a network analysis using a VBScript-based Element Script evaluator.

Because it will no longer be possible to build a network dataset that has VBScript-based evaluators, it will not be possible to make any edits to the network dataset properties or source feature classes that trigger the need for a network rebuild without also updating the evaluators.

What will still work

Solving a network analysis using a network with VBScript-based Field Script evaluators will continue to work, so these networks can still be used as long as they do not require any edits.

Migrating VBScript-based evaluators to Python

To retain the full network dataset functionality throughout the new releases of ArcGIS Pro, the VBScript-based Field Script and Element Script evaluators must be updated to use Python. Attributes configured with VBScript evaluators display warning messages in the network dataset property pages as shown in the image sample below.

Note:
Some attributes may display other, unrelated warning messages.
The Network Dataset Properties dialog box in ArcGIS Pro.

How to update Field Script evaluators

The main difference between coding in VBScript and Python is that fields in VBScript are bracketed in square brackets, while in Python they are bracketed with exclamation points. To visualize this, the field MINUTES will be used to provide an example below:

In VBScript, the fields are coded in square brackets.

[MINUTES]

In Python, the fields are coded in exclamation points.

!MINUTES!

As many Field Script evaluators reference a single field in the source feature class, updating the expressions from VBScript to Python will mainly require replacing the square brackets with exclamation points. More complex VBScript code will require a more substantial code translation. To change the code from VBScript to Python, proceed with the following steps:

  1. In ArcGIS Pro, open the Network Dataset Properties dialog box. Refer to ArcGIS Pro: Access network attributes for further instructions.
  2. Click the Costs tab.
  3. In the Evaluators section, expand the Edges node.
The Edges source feature table in ArcGIS Pro.
  1. Navigate to the feature with a Field Script evaluator type, double-click the Value column, and click the Evaluator Settings The Evaluator Settings button. button.
The Edges source feature table in ArcGIS Pro.
Note:
When the Field Script Evaluator Properties dialog box is opened, a warning message is displayed and the code boxes are locked, rendering them unenditable, as shown in the image below.
The Field Script Evaluator Properties dialog box in ArcGIS Pro.
  1. In the Field Script Evaluator Properties dialog box, click the Language drop-down menu and select Python.
The Language drop-down menu in the Field Script Evaluator dialog box in ArcGIS Pro.
  1. The code boxes are now editable. Existing VBScript code and warning message is removed.
The code boxes in the Field Script Evaluator Properties dialog box in ArcGIS Pro.
  1. Replace the VBScript code with the Python equivalent. In this case, the square brackets bracketing the field are replaced with exclamation points.
The code boxes in the Field Script Evaluator Properties dialog box in ArcGIS Pro.
  1. Click OK.
  2. Repeat steps 1 to 8 for the other Edges, Junctions, and Turns source features. Refer to ArcGIS Pro: Field Script evaluator examples for more information.

The image below shows the evaluator configuration for the edges source of the attribute updated.

The Edges source feature table in ArcGIS Pro.

How to update Element Script evaluators

The workflow to update VBScript-based Element Script evaluators is similar to the Field Script evaluator workflow detailed above. However, the coding in Element Script evaluators is not as straightforward as coding in Field Script evaluators, as the coding is specific to the type of element used as well as the user’s unique application. Hence, there is no consistent formula to convert the VBScript coding to a Python coding, and the user must fully understand the original coding and rewrite it to fit the Python syntax. However, the AttributeValueByName() and ParameterValueByName() helper methods are coded the same in both languages, so these do not need to be updated. Refer to ArcGIS Pro: Element Script evaluator examples for more information.

Article ID: 000034321

Software:
  • ArcGIS Pro 3 3
  • ArcGIS Pro 3 2
  • ArcGIS Pro 3 4

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options