This document is archived and information here might be outdated.  Recommended version.


How to create a network dataset (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with feature data > Network datasets > How to create a network dataset

How to create a network dataset


Summary
This topic shows how to create a simple geodatabase network dataset. The procedure described in this topic constructs the network dataset exactly as it is constructed in Exercise 1 of the ArcGIS Network Analyst extension Tutorial (referenced in the See Also link at the end of this topic).

In this topic


Creating a network dataset data element

The network dataset being created is based on the SanFrancisco.gdb file geodatabase data located in <your ArcGIS Developer Kit install location>\Samples\data. First, a network dataset data element will be created, the Transportation feature dataset will be opened, and its extent and spatial reference information copied to the data element. The network dataset will be named Streets_ND. Make a backup copy of SanFrancisco.gdb, then delete the network dataset from the main copy. This topic will recreate that dataset.
This topic uses the geodatabase file, SanFrancisco.gdb, which is installed in the C:\arcgis\ArcTutor\Network_Analyst\Tutorial\Exercise01 folder. If you have the ArcGIS Tutorial Data installed, you can modify the OpenFromFile() call in the following code example to create the network dataset in that file geodatabase instead.
Do the following steps to create a network dataset data element:
  1. Create an empty data element for a buildable network dataset.
  2. Open the feature dataset and CType to the IGeoDataset interface.
  3. Copy the feature dataset's extent and spatial reference to the network dataset data element.
  4. Name the network dataset, Streets_ND.
See the following code example:
[VB.NET]
' Create an empty data element for a buildable network dataset.
Dim deND As IDENetworkDataset2=New DENetworkDataset
deND.Buildable=True

' Open the feature dataset and CType to the IGeoDataset interface.
Dim factoryType As Type=Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory")
Dim gdbWSF As IWorkspaceFactory=CType(Activator.CreateInstance(factoryType), IWorkspaceFactory)
Dim gdbFWS As IFeatureWorkspace=CType(gdbWSF.OpenFromFile("C:\Program Files\ArcGIS\DeveloperKit10.0\Samples\data\SanFrancisco.gdb", 0), IFeatureWorkspace)
Dim fdsGDS As IGeoDataset=CType(gdbFWS.OpenFeatureDataset("Transportation"), IGeoDataset)

' Copy the feature dataset's extent and spatial reference to the network dataset data element.
Dim deGDS As IDEGeoDataset=CType(deND, IDEGeoDataset)
deGDS.Extent=fdsGDS.Extent
deGDS.SpatialReference=fdsGDS.SpatialReference

' Specify the name of the network dataset.
Dim dataElement As IDataElement=CType(deND, IDataElement)
dataElement.Name="Streets_ND"
[C#]
// Create an empty data element for a buildable network dataset.
IDENetworkDataset2 deNetworkDataset=new DENetworkDatasetClass();
deNetworkDataset.Buildable=true;

// Open the feature dataset and cast to the IGeoDataset interface.
Type factoryType=Type.GetTypeFromProgID(
    "esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory workspaceFactory=(IWorkspaceFactory)Activator.CreateInstance
    (factoryType);
IWorkspace workspace=workspaceFactory.OpenFromFile(@
    "C:\Program Files\ArcGIS\DeveloperKit10.0\Samples\data\SanFrancisco.gdb", 0);
IFeatureWorkspace featureWorkspace=(IFeatureWorkspace)workspace;
IFeatureDataset featureDataset=featureWorkspace.OpenFeatureDataset(
    "Transportation");
IGeoDataset geoDataset=(IGeoDataset)featureDataset;

// Copy the feature dataset's extent and spatial reference to the network dataset data element.
IDEGeoDataset deGeoDataset=(IDEGeoDataset)deNetworkDataset;
deGeoDataset.Extent=geoDataset.Extent;
deGeoDataset.SpatialReference=geoDataset.SpatialReference;

// Specify the name of the network dataset.
IDataElement dataElement=(IDataElement)deNetworkDataset;
dataElement.Name="Streets_ND";

Adding network sources

The network dataset will be created with two network sources: Streets feature class and RestrictedTurns feature class. The Streets feature class becomes an edge source in the network dataset and the RestrictedTurns feature class becomes a turn source.

Specifying connectivity settings for the edge source

The Streets feature class needs to be an edge feature source in the network dataset with the appropriate connectivity and directions settings. The following is from the New Network Dataset wizard's summary for the source's connectivity settings:
Connectivity:
  Group 1:
    Edge Connectivity:
      Streets (End Point)
Elevation Model: Elevation Fields
  Edge Elevation Fields: (From End, To End):
    Streets: (F_ELEV, T_ELEV)
The following code example shows connectivity settings that will be used when creating an EdgeFeatureSource object:
[VB.NET]
' Specify the network dataset's elevation model.
deND.ElevationModel=esriNetworkElevationModel.esriNEMElevationFields

' Create an EdgeFeatureSource object and point it to the Streets feature class.
Dim edgeNetSource As INetworkSource=New EdgeFeatureSource
edgeNetSource.Name="Streets"
edgeNetSource.ElementType=esriNetworkElementType.esriNETEdge

' Set the edge feature source's connectivity settings.
Dim edgeFS As IEdgeFeatureSource=CType(edgeNetSource, IEdgeFeatureSource)
With edgeFS
    .UsesSubtypes=False
    .ClassConnectivityGroup=1
    .ClassConnectivityPolicy=esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex
    .FromElevationFieldName="F_ELEV"
    .ToElevationFieldName="T_ELEV"
End With
[C#]
// Specify the network dataset's elevation model.
deNetworkDataset.ElevationModel=esriNetworkElevationModel.esriNEMElevationFields;

// Create an EdgeFeatureSource object and point it to the Streets feature class.
INetworkSource edgeNetworkSource=new EdgeFeatureSourceClass();
edgeNetworkSource.Name="Streets";
edgeNetworkSource.ElementType=esriNetworkElementType.esriNETEdge;

// Set the edge feature source's connectivity settings.
IEdgeFeatureSource edgeFeatureSource=(IEdgeFeatureSource)edgeNetworkSource;
edgeFeatureSource.UsesSubtypes=false;
edgeFeatureSource.ClassConnectivityGroup=1;
edgeFeatureSource.ClassConnectivityPolicy =
    esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex;
edgeFeatureSource.FromElevationFieldName="F_ELEV";
edgeFeatureSource.ToElevationFieldName="T_ELEV";

Specifying directions settings for the edge source

The edge source also has settings used when generating driving directions and identifying the fields that contain the street names. The following is from the New Network Dataset wizard's summary for the source's directions settings:
Source Directions:
    Streets:
      Street Name Fields:
        Primary:
          Name: NAME
The following directions settings will be used when creating a StreetNameFields object. This object will be added to the previously created EdgeFeatureSource object:
[VB.NET]
' Create a StreetNameFields object and populate its settings.
Dim snf As IStreetNameFields=New StreetNameFields
With snf
    .Priority=1 'Priority 1 indicates the primary street name.
    .StreetNameFieldName="NAME"
End With

' Add the StreetNameFields object to a new NetworkSourceDirections object,
' then add it to the EdgeFeatureSource created earlier.
Dim nsd As INetworkSourceDirections=New NetworkSourceDirections
Dim snfArray As IArray=New ESRI.ArcGIS.esriSystem.Array
snfArray.Add(snf)
nsd.StreetNameFields=snfArray
edgeNetSource.NetworkSourceDirections=nsd
[C#]
// Create a StreetNameFields object and populate its settings.
IStreetNameFields streetNameFields=new StreetNameFieldsClass();
streetNameFields.Priority=1; // Priority 1 indicates the primary street name.
streetNameFields.StreetNameFieldName="NAME";

// Add the StreetNameFields object to a new NetworkSourceDirections object,
// then add it to the EdgeFeatureSource created earlier.
INetworkSourceDirections nsDirections=new NetworkSourceDirectionsClass();
IArray nsdArray=new ArrayClass();
nsdArray.Add(streetNameFields);
nsDirections.StreetNameFields=nsdArray;
edgeNetworkSource.NetworkSourceDirections=nsDirections;

Specifying the turn source

The network dataset will have a turn feature source referencing the RestrictedTurns feature class.
Specify on the data element that the network dataset supports turns, then create the TurnFeatureSource object. See the following code example:
[VB.NET]
deND.SupportsTurns=True

' Create a TurnFeatureSource object and point it to the RestrictedTurns feature class.
Dim turnNetSource As INetworkSource=New TurnFeatureSource
turnNetSource.Name="RestrictedTurns"
turnNetSource.ElementType=esriNetworkElementType.esriNETTurn
[C#]
deNetworkDataset.SupportsTurns=true;

// Create a TurnFeatureSource object and point it to the RestrictedTurns feature class.
INetworkSource turnNetworkSource=new TurnFeatureSourceClass();
turnNetworkSource.Name="RestrictedTurns";
turnNetworkSource.ElementType=esriNetworkElementType.esriNETTurn;
Now that all the sources have been created, they can be added to the array, then the array can be added to the network dataset data element. See the following code example:
[VB.NET]
Dim sourceArray As IArray=New ESRI.ArcGIS.esriSystem.Array
With sourceArray
    .Add(edgeNetSource)
    .Add(turnNetSource)
End With

deND.Sources=sourceArray
[C#]
IArray sourceArray=new ArrayClass();
sourceArray.Add(edgeNetworkSource);
sourceArray.Add(turnNetworkSource);

deNetworkDataset.Sources=sourceArray;

Adding the traffic data tables

This network dataset will be created with historical traffic data. The historical traffic data consists of two tables: the speed profile table and the street-speed profile join table. The following is from the New Network Dataset wizard's summary for the historical traffic settings:
  Speed Profile Table:
    Table: DailyProfiles
    First Time Slice Field: SpeedFactor_0000
    Last Time Slice Field: TimeFactor_2355
    Minutes Per Time Slice: 5
    First Time Slice Start Time: 12 AM
    Last Time Slice Finish Time: 12 AM
  Street - Speed Profile Join Table:
    Table: Streets_DailyProfiles
    Base Speed Field: SPFREEFLOW
    Base Speed Units: KPH
    Sunday ProfileID Field: PROFILE_1
    Monday ProfileID Field: PROFILE_2
    Tuesday ProfileID Field: PROFILE_3
    Wednesday ProfileID Field: PROFILE_4
    Thursday ProfileID Field: PROFILE_5
    Friday ProfileID Field: PROFILE_6
    Saturday ProfileID Field: PROFILE_7
The above historical traffic settings will be used when creating a new TrafficData object. See the following code:
[VB.NET]
' Create a new TrafficData object and populate its historical traffic settings.
Dim traffData As ITrafficData2=New TrafficData
traffData.LengthAttributeName="Meters"

Dim histTraff As IHistoricalTrafficData2=CType(traffData, IHistoricalTrafficData2)

With histTraff
    ' Populate the speed profile table settings.
    .ProfilesTableName="DailyProfiles"
    .FirstTimeSliceFieldName="SpeedFactor_0000"
    .LastTimeSliceFieldName="SpeedFactor_2355"
    .TimeSliceDurationInMinutes=5
    .FirstTimeSliceStartTime=New DateTime(1, 1, 1, 0, 0, 0) ' 12 AM
    ' Note: the last time slice finish time is implied from the above settings and need not be specified.
    
    ' Populate the street-speed profile join table settings.
    .JoinTableName="Streets_DailyProfiles"
    .JoinTableBaseSpeedFieldName="SPFREEFLOW"
    .JoinTableBaseSpeedUnits=esriNetworkAttributeUnits.esriNAUKilometersPerHour
    Dim fieldNames As IStringArray=New Names
    With fieldNames
        .Add("PROFILE_1")
        .Add("PROFILE_2")
        .Add("PROFILE_3")
        .Add("PROFILE_4")
        .Add("PROFILE_5")
        .Add("PROFILE_6")
        .Add("PROFILE_7")
    End With
    .JoinTableProfileIDFieldNames=fieldNames
End With

' Add the traffic data to the network dataset data element.
deND.TrafficData=CType(histTraff, ITrafficData)
[C#]
// Create a new TrafficData object and populate its historical traffic settings.
var traffData=new TrafficDataClass()as ITrafficData2;
traffData.LengthAttributeName="Meters";

var histTraff=traffData as IHistoricalTrafficData2;

// Populate the speed profile table settings.
histTraff.ProfilesTableName="DailyProfiles";
histTraff.FirstTimeSliceFieldName="SpeedFactor_0000";
histTraff.LastTimeSliceFieldName="SpeedFactor_2355";
histTraff.TimeSliceDurationInMinutes=5;
histTraff.FirstTimeSliceStartTime=new DateTime(1, 1, 1, 0, 0, 0); // 12 AM

// Note: the last time slice finish time is implied from the above settings and need not be specified.
// Populate the street-speed profile join table settings.
histTraff.JoinTableName="Streets_DailyProfiles";
histTraff.JoinTableBaseSpeedFieldName="SPFREEFLOW";
histTraff.JoinTableBaseSpeedUnits =
    esriNetworkAttributeUnits.esriNAUKilometersPerHour;
IStringArray fieldNames=new NamesClass();
fieldNames.Add("PROFILE_1");
fieldNames.Add("PROFILE_2");
fieldNames.Add("PROFILE_3");
fieldNames.Add("PROFILE_4");
fieldNames.Add("PROFILE_5");
fieldNames.Add("PROFILE_6");
fieldNames.Add("PROFILE_7");
histTraff.JoinTableProfileIDFieldNames=fieldNames;

// Add the traffic data to the network dataset data element.
deNetworkDataset.TrafficData=(ITrafficData)histTraff;

Adding network attributes

The network dataset will be created with the following network attributes:
  • Oneway network attribute
  • Minutes network attribute
  • Meters network attribute
  • RoadClass network attribute
  • WeekdayFallbackTravelTime attribute
  • WeekendFallbackTravelTime attribute
  • TravelTime attribute
  • RestrictedTurns network attribute
  • HierarchyMultiNet network attribute
An empty array for the network attributes will be created, then each attribute will be created and added to the array. See the following code example:
[VB.NET]
Dim attrArray As IArray=New ESRI.ArcGIS.esriSystem.Array

' Initialize variables reused when creating attributes:
Dim evalNetAttr As IEvaluatedNetworkAttribute
Dim netAttr2 As INetworkAttribute2
Dim netFieldEval As INetworkFieldEvaluator
Dim netConstEval As INetworkConstantEvaluator
[C#]
IArray attributeArray=new ArrayClass();

// Initialize variables reused when creating attributes:
IEvaluatedNetworkAttribute evalNetAttr;
INetworkAttribute2 netAttr2;
INetworkFieldEvaluator netFieldEval;
INetworkConstantEvaluator netConstEval;

Oneway network attribute

The following is from the New Network Dataset wizard's summary for the Oneway network attribute:
Oneway:
    Usage Type: Restriction
    Data Type: Boolean
    Units Type: Unknown
    Use by Default: True
    Source Attribute Evaluators:
      Streets (From-To): Field -
          Prelogic:
            restricted=False
            Select Case UCase([ONEWAY])
              Case "N", "TF", "T": restricted=True
            End Select
          Expression: restricted
      Streets (To-From): Field -
          Prelogic:
            restricted=False
            Select Case UCase([ONEWAY])
              Case "N", "FT", "F": restricted=True
            End Select
          Expression: restricted
    Default Attribute Evaluators:
      Default Edges: Constant - Traversable
      Default Junctions: Constant - Traversable
      Default Turns: Constant - Traversable
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="Oneway"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTRestriction
    .DataType=esriNetworkAttributeDataType.esriNADTBoolean
    .Units=esriNetworkAttributeUnits.esriNAUUnknown
    .UseByDefault=True
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("restricted", _
                           "restricted=False" & vbNewLine & _
                           "Select Case UCase([ONEWAY])" & vbNewLine & _
                           "  Case ""N"", ""TF"", ""T"": restricted=True" & vbNewLine & _
                           "End Select")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("restricted", _
                           "restricted=False" & vbNewLine & _
                           "Select Case UCase([ONEWAY])" & vbNewLine & _
                           "  Case ""N"", ""FT"", ""F"": restricted=True" & vbNewLine & _
                           "End Select")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=False 'False means Traversable (that is, not restricted).
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=False
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=False
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="Oneway";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTRestriction;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTBoolean;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUUnknown;
netAttr2.UseByDefault=true;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("restricted", "restricted=False\n\r" + 
    "Select Case UCase([ONEWAY])\n\r" + 
    "  Case \"N\", \"TF\", \"T\": restricted=True\n\r" + "End Select");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("restricted", "restricted=False\n\r" + 
    "Select Case UCase([ONEWAY])\n\r" + 
    "  Case \"N\", \"FT\", \"F\": restricted=True\n\r" + "End Select");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false; // False=traversable.
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

Minutes network attribute

The following is from the New Network Dataset wizard's summary for the Minutes network attribute:
Minutes:
    Usage Type: Cost
    Data Type: Double
    Units Type: Minutes
    Use by Default: False
    Source Attribute Evaluators:
      Streets (From-To): Field - [MINUTES]
      Streets (To-From): Field - [MINUTES]
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="Minutes"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTCost
    .DataType=esriNetworkAttributeDataType.esriNADTDouble
    .Units=esriNetworkAttributeUnits.esriNAUMinutes
    .UseByDefault=False
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[MINUTES]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[MINUTES]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="Minutes";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTCost;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTDouble;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUMinutes;
netAttr2.UseByDefault=false;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[MINUTES]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[MINUTES]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

Meters network attribute

The following is from the New Network Dataset wizard's summary for the Meters network attribute:
Meters:
    Usage Type: Cost
    Data Type: Double
    Units Type: Meters
    Use by Default: False
    Source Attribute Evaluators:
      Streets (From-To): Field - [METERS]
      Streets (To-From): Field - [METERS]
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="Meters"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTCost
    .DataType=esriNetworkAttributeDataType.esriNADTDouble
    .Units=esriNetworkAttributeUnits.esriNAUMeters
    .UseByDefault=False
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[METERS]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[METERS]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="Meters";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTCost;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTDouble;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUMeters;
netAttr2.UseByDefault=false;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[METERS]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[METERS]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

RoadClass network attribute

The following is from the New Network Dataset wizard's summary for the RoadClass network attribute:
RoadClass:
    Usage Type: Descriptor
    Data Type: Integer
    Units Type: Unknown
    Use by Default: False
    Source Attribute Evaluators:
      Streets (From-To): Field -
          Prelogic:
            rc=1          'Local road
            If [FEATTYP]=4130 Then
              rc=4          'Ferry
            Else
              Select Case [FOW]
                Case 1: rc=2          'Highway
                Case 10: rc=3          'Ramp
                Case 4: rc=5          'Roundabout
              End Select
            End If
          Expression: rc
      Streets (To-From): Field -
          Prelogic:
            rc=1          'Local road
            If [FEATTYP]=4130 Then
              rc=4          'Ferry
            Else
              Select Case [FOW]
                Case 1: rc=2          'Highway
                Case 10: rc=3          'Ramp
                Case 4: rc=5          'Roundabout
              End Select
            End If
          Expression: rc
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="RoadClass"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTDescriptor
    .DataType=esriNetworkAttributeDataType.esriNADTInteger
    .Units=esriNetworkAttributeUnits.esriNAUUnknown
    .UseByDefault=False
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("rc", _
                           "rc=1          'Local road" & vbNewLine & _
                           "If [FEATTYP]=4130 Then" & vbNewLine & _
                           "  rc=4          'Ferry" & vbNewLine & _
                           "Else" & vbNewLine & _
                           "  Select Case [FOW]" & vbNewLine & _
                           "    Case 1: rc=2          'Highway" & vbNewLine & _
                           "    Case 10: rc=3          'Ramp" & vbNewLine & _
                           "    Case 4: rc=5          'Roundabout" & vbNewLine & _
                           "  End Select" & vbNewLine & _
                           "End If")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("rc", _
                           "rc=1 'Local road" & vbNewLine & _
                           "If [FEATTYP]=4130 Then" & vbNewLine & _
                           " rc=4 'Ferry" & vbNewLine & _
                           "Else" & vbNewLine & _
                           " Select Case [FOW]" & vbNewLine & _
                           "   Case 1: rc=2 'Highway" & vbNewLine & _
                           "   Case 10: rc=3 'Ramp" & vbNewLine & _
                           "   Case 4: rc=5 'Roundabout" & vbNewLine & _
                           " End Select" & vbNewLine & _
                           "End If")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="RoadClass";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTDescriptor;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTInteger;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUUnknown;
netAttr2.UseByDefault=false;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("rc", "rc=1          'Local road\n\r" + 
    "If [FEATTYP]=4130 Then\n\r" + "  rc=4          'Ferry\n\r" + "Else\n\r" + 
    "  Select Case [FOW]\n\r" + "    Case 1: rc=2          'Highway\n\r" + 
    "    Case 10: rc=3          'Ramp\n\r" + 
    "    Case 4: rc=5          'Roundabout\n\r" + "  End Select\n\r" + "End If");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("rc", "rc=1 'Local road\n\r" + 
    "If [FEATTYP]=4130 Then\n\r" + " rc=4 'Ferry\n\r" + "Else\n\r" + 
    " Select Case [FOW]\n\r" + " Case 1: rc=2 'Highway\n\r" + 
    " Case 10: rc=3 'Ramp\n\r" + " Case 4: rc=5 'Roundabout\n\r" + 
    " End Select\n\r" + "End If");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

WeekdayFallbackTravelTime network attribute

The following is from the New Network Dataset wizard's summary for the WeekdayFallbackTravelTime network attribute:
WeekdayFallbackTravelTime:
    Usage Type: Cost
    Data Type: Double
    Units Type: Minutes
    Use by Default: False
    Source Attribute Evaluators:
      Streets (From-To): Field - [FT_WeekdayMinutes]
      Streets (To-From): Field - [TF_WeekdayMinutes]
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="WeekdayFallbackTravelTime"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTCost
    .DataType=esriNetworkAttributeDataType.esriNADTDouble
    .Units=esriNetworkAttributeUnits.esriNAUMinutes
    .UseByDefault=False
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[FT_WeekdayMinutes]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[TF_WeekdayMinutes]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="WeekdayFallbackTravelTime";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTCost;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTDouble;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUMinutes;
netAttr2.UseByDefault=false;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[FT_WeekdayMinutes]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[TF_WeekdayMinutes]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

WeekendFallbackTravelTime network attribute

The following is from the New Network Dataset wizard's summary for the WeekendFallbackTravelTime network attribute:
WeekendFallbackTravelTime:
    Usage Type: Cost
    Data Type: Double
    Units Type: Minutes
    Use by Default: False
    Source Attribute Evaluators:
      Streets (From-To): Field - [FT_WeekendMinutes]
      Streets (To-From): Field - [TF_WeekendMinutes]
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="WeekendFallbackTravelTime"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTCost
    .DataType=esriNetworkAttributeDataType.esriNADTDouble
    .Units=esriNetworkAttributeUnits.esriNAUMinutes
    .UseByDefault=False
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[FT_WeekendMinutes]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[TF_WeekendMinutes]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="WeekendFallbackTravelTime";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTCost;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTDouble;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUMinutes;
netAttr2.UseByDefault=false;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[FT_WeekendMinutes]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[TF_WeekendMinutes]", "");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

TravelTime network attribute

The following is from the New Network Dataset wizard's summary for the TravelTime network attribute:
TravelTime:
    Usage Type: Cost
    Data Type: Double
    Units Type: Minutes
    Use by Default: True
    Source Attribute Evaluators:
      Streets (From-To): Edge Traffic
        Weekday Fallback Attribute: WeekdayFallbackTravelTime
        Weekend Fallback Attribute: WeekendFallbackTravelTime
        Time Neutral Attribute: Minutes
      Streets (To-From): Edge Traffic
        Weekday Fallback Attribute: WeekdayFallbackTravelTime
        Weekend Fallback Attribute: WeekendFallbackTravelTime
        Time Neutral Attribute: Minutes
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="TravelTime"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTCost
    .DataType=esriNetworkAttributeDataType.esriNADTDouble
    .Units=esriNetworkAttributeUnits.esriNAUMinutes
    .UseByDefault=True
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
Dim histTravelTimeEval As IHistoricalTravelTimeEvaluator=New NetworkEdgeTrafficEvaluator
histTravelTimeEval.WeekdayFallbackAttributeName="WeekdayFallbackTravelTime"
histTravelTimeEval.WeekendFallbackAttributeName="WeekendFallbackTravelTime"
histTravelTimeEval.TimeNeutralAttributeName="Minutes"
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(histTravelTimeEval, INetworkEvaluator)

histTravelTimeEval=New NetworkEdgeTrafficEvaluator
histTravelTimeEval.WeekdayFallbackAttributeName="WeekdayFallbackTravelTime"
histTravelTimeEval.WeekendFallbackAttributeName="WeekendFallbackTravelTime"
histTravelTimeEval.TimeNeutralAttributeName="Minutes"
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(histTravelTimeEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="TravelTime";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTCost;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTDouble;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUMinutes;
netAttr2.UseByDefault=true;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
IHistoricalTravelTimeEvaluator histTravelTimeEval=new
    NetworkEdgeTrafficEvaluatorClass();
histTravelTimeEval.WeekdayFallbackAttributeName="WeekdayFallbackTravelTime";
histTravelTimeEval.WeekendFallbackAttributeName="WeekendFallbackTravelTime";
histTravelTimeEval.TimeNeutralAttributeName="Minutes";
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)
    histTravelTimeEval);

histTravelTimeEval=new NetworkEdgeTrafficEvaluatorClass();
histTravelTimeEval.WeekdayFallbackAttributeName="WeekdayFallbackTravelTime";
histTravelTimeEval.WeekendFallbackAttributeName="WeekendFallbackTravelTime";
histTravelTimeEval.TimeNeutralAttributeName="Minutes";
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    histTravelTimeEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

RestrictedTurns network attribute

The following is from the New Network Dataset wizard's summary for the RestrictedTurns network attribute:
RestrictedTurns:
    Usage Type: Restriction
    Data Type: Boolean
    Units Type: Unknown
    Use by Default: True
    Source Attribute Evaluators: 
      RestrictedTurns: Constant - Restricted
    Default Attribute Evaluators:
      Default Edges: Constant - Traversable
      Default Junctions: Constant - Traversable
      Default Turns: Constant - Traversable 
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="RestrictedTurns"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTRestriction
    .DataType=esriNetworkAttributeDataType.esriNADTBoolean
    .Units=esriNetworkAttributeUnits.esriNAUUnknown
    .UseByDefault=True
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=True 'True means Restricted.
evalNetAttr.Evaluator(turnNetSource, esriNetworkEdgeDirection.esriNEDNone)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=False 'False means Traversable (that is, not restricted).
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=False
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=False
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="RestrictedTurns";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTRestriction;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTBoolean;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUUnknown;
netAttr2.UseByDefault=true;

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=true;
evalNetAttr.set_Evaluator(turnNetworkSource, esriNetworkEdgeDirection.esriNEDNone, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

HierarchyMultiNet network attribute

The following is from the New Network Dataset wizard's summary for the HierarchyMultiNet network attribute:
HierarchyMultiNet:
    Usage Type: Hierarchy
    Data Type: Integer
    Units Type: Unknown
    Use by Default: False
    Hierarchy Ranges:
      Primary Roads: up to 2
      Secondary Roads: 3 - 4
      Local Roads: 5 and higher
    Source Attribute Evaluators:
      Streets (From-To): Field -
          Prelogic:
            h=[NET2CLASS] + 1
            if h > 5 Then h=5
          Expression: h
      Streets (To-From): Field -
          Prelogic:
            h=[NET2CLASS] + 1
            if h > 5 Then h=5
          Expression: h
    Default Attribute Evaluators:
      Default Edges: Constant - 0
      Default Junctions: Constant - 0
      Default Turns: Constant - 0
See the following code example:
[VB.NET]
' Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=New EvaluatedNetworkAttribute
netAttr2=CType(evalNetAttr, INetworkAttribute2)
With netAttr2
    .Name="HierarchyMultiNet"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTHierarchy
    .DataType=esriNetworkAttributeDataType.esriNADTInteger
    .Units=esriNetworkAttributeUnits.esriNAUUnknown
    .UseByDefault=True
End With

' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("h", _
                           "h=[NET2CLASS] + 1" & vbNewLine & _
                           "If h > 5 Then h=5")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("h", _
                           "h=[NET2CLASS] + 1" & vbNewLine & _
                           "If h > 5 Then h=5")
evalNetAttr.Evaluator(edgeNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETEdge)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETJunction)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=0
evalNetAttr.DefaultEvaluator(esriNetworkElementType.esriNETTurn)=CType(netConstEval, INetworkEvaluator)

' Add the attribute to the array.
attrArray.Add(evalNetAttr)

' Since this is the hierarchy attribute, also set it as the hierarchy cluster attribute.
deND.HierarchyClusterAttribute=CType(evalNetAttr, INetworkAttribute)

' Specify the ranges for the hierarchy levels.
With deND
    .HierarchyLevelCount=3
    .MaxValueForHierarchy(1)=2 ' level 1: up to 2
    .MaxValueForHierarchy(2)=4 ' level 2: 3 - 4
    .MaxValueForHierarchy(3)=5 ' level 3: 5 and higher (the values of h only go up to 5)
End With
[C#]
// Create an EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr=new EvaluatedNetworkAttributeClass();
netAttr2=(INetworkAttribute2)evalNetAttr;
netAttr2.Name="HierarchyMultiNet";
netAttr2.UsageType=esriNetworkAttributeUsageType.esriNAUTHierarchy;
netAttr2.DataType=esriNetworkAttributeDataType.esriNADTInteger;
netAttr2.Units=esriNetworkAttributeUnits.esriNAUUnknown;
netAttr2.UseByDefault=true;

// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("h", "h=[NET2CLASS] + 1\n\r" + "if h > 5 then h=5");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("h", "h=[NET2CLASS] + 1\n\r" + "if h > 5 then h=5");
evalNetAttr.set_Evaluator(edgeNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, 
    (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=0;
evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, 
    (INetworkEvaluator)netConstEval);

// Add the attribute to the array.
attributeArray.Add(evalNetAttr);

// Since this is the hierarchy attribute, also set it as the hierarchy cluster attribute.
deNetworkDataset.HierarchyClusterAttribute=(INetworkAttribute)evalNetAttr;

// Specify the ranges for the hierarchy levels.
deNetworkDataset.HierarchyLevelCount=3;
deNetworkDataset.set_MaxValueForHierarchy(1, 2); // level 1: up to 2
deNetworkDataset.set_MaxValueForHierarchy(2, 4); // level 2: 3 - 4
deNetworkDataset.set_MaxValueForHierarchy(3, 5); 
    // level 3: 5 and higher (the values of h only go up to 5)
Now that all the attributes have been added to the array, the array to the network dataset data element can be added. See the following code example:
[VB.NET]
deND.Attributes=attrArray
[C#]
deNetworkDataset.Attributes=attributeArray;

Specifying directions settings

The network dataset has settings for generating driving directions. The source-specific settings were specified when the EdgeFeatureSource was created. Next, the general settings will be specified.

General directions settings

The following is from the New Network Dataset wizard's summary for the General Directions settings:
  General Directions:
    Display Length Units: Miles
    Length Attribute: Meters
    Time Attribute: Minutes
    Signpost Feature Class: Signposts
    Signpost Streets Table: Signposts_Streets
    Road Detail:
      Road Class Attribute: RoadClass
These directions settings will be used when creating a NetworkDirections object, then the object will be added to the network dataset data element object. See the following code example:
[VB.NET]
' Create a NetworkDirections object and populate its settings.
Dim netDirections As INetworkDirections=New NetworkDirections
With netDirections
    .DefaultOutputLengthUnits=esriNetworkAttributeUnits.esriNAUMiles
    .LengthAttributeName="Meters"
    .TimeAttributeName="Minutes"
    .RoadClassAttributeName="RoadClass"
End With
Dim netDirSignposts As ISignposts=CType(netDirections, ISignposts)
netDirSignposts.SignpostFeatureClassName="Signposts"
netDirSignposts.SignpostStreetsTableName="Signposts_Streets"

' Add the NetworkDirections object to the network dataset data element.
deND.Directions=netDirections
[C#]
// Create a NetworkDirections object and populate its settings.
INetworkDirections networkDirections=new NetworkDirectionsClass();
networkDirections.DefaultOutputLengthUnits=esriNetworkAttributeUnits.esriNAUMiles;
networkDirections.LengthAttributeName="Meters";
networkDirections.TimeAttributeName="Minutes";
networkDirections.RoadClassAttributeName="RoadClass";
ISignposts netDirSignposts=(ISignposts)networkDirections;
netDirSignposts.SignpostFeatureClassName="Signposts";
netDirSignposts.SignpostStreetsTableName="Signposts_Streets";

// Add the NetworkDirections object to the network dataset data element.
deNetworkDataset.Directions=networkDirections;

Creating and building the network dataset

All the network dataset settings are now included on the data element, and the network dataset can be created. A network dataset is created through the Network Dataset Feature Dataset extension. Once the network dataset is created, build it using the INetworkBuild interface. See the following code example:
[VB.NET]
' Get the feature dataset extension and create the network dataset based on the data element.
Dim fdxc As IFeatureDatasetExtensionContainer=CType(fdsGDS, IFeatureDatasetExtensionContainer)
Dim fdx As IFeatureDatasetExtension=fdxc.FindExtension(esriDatasetType.esriDTNetworkDataset)
Dim dsc2 As IDatasetContainer2=CType(fdx, IDatasetContainer2)
Dim netDataset As INetworkDataset=CType(dsc2.CreateDataset(deND), INetworkDataset)

' Once the network dataset is created, build it.
Dim netBuild As INetworkBuild=CType(netDataset, INetworkBuild)
netBuild.BuildNetwork(fdsGDS.Extent)
[C#]
// Get the feature dataset extension and create the network dataset based on the data element.
IFeatureDatasetExtensionContainer fdxContainer=(IFeatureDatasetExtensionContainer)
    featureDataset;
IFeatureDatasetExtension fdExtension=fdxContainer.FindExtension
    (esriDatasetType.esriDTNetworkDataset);
IDatasetContainer2 datasetContainer2=(IDatasetContainer2)fdExtension;
IDEDataset deDataset=(IDEDataset)deNetworkDataset;
INetworkDataset networkDataset=(INetworkDataset)datasetContainer2.CreateDataset
    (deDataset);

// Once the network dataset is created, build it.
INetworkBuild networkBuild=(INetworkBuild)networkDataset;
networkBuild.BuildNetwork(geoDataset.Extent);


See Also:

What is ArcGIS Network Analyst extension?
About the ArcGIS Network Analyst extension Tutorial
Exercise 1: Create a network dataset
Geodatabase
What is a network dataset?




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic: Network Analyst
ArcGIS Desktop Standard ArcGIS Desktop Standard: Network Analyst
ArcGIS Desktop Advanced ArcGIS Desktop Advanced: Network Analyst
Engine Developer Kit Engine: Network Analyst