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


How to create a multimodal network dataset (ArcObjects .NET 10.5 SDK)

How to create a multimodal network dataset


Summary
This topic demonstrates how to create a multimodal network dataset from multiple feature classes in a geodatabase feature dataset. The procedure described in this topic constructs the network dataset exactly as it is constructed in Exercise 2 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 Paris.gdb file geodatabase data located in the ArcGIS Network Analyst extension tutorial. 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 ParisMultimodal_ND.
This topic uses the geodatabase file, Paris.gdb, which is installed in the C:\arcgis\ArcTutor\Network_Analyst\Tutorial\Exercise02 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, ParisMultimodal_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:\arcgis\ArcTutor\Network_Analyst\Tutorial\Exercise02\Paris.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="ParisMultimodal_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:\arcgis\ArcTutor\Network_Analyst\Tutorial\Exercise02\Paris.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="ParisMultimodal_ND";

Adding network sources

The network dataset will be created with six network sources, four line feature classes, and two point feature classes. The line feature classes become edge sources in the network dataset and the point feature classes become junction sources:
Sources:
  Edge Sources:
    Metro_Lines
    Streets
    Transfer_Stations
    Transfer_Street_Station
  Junction Sources:
    Metro_Entrances
    Metro_Stations

Specifying the connectivity settings for the edge and junction source

The feature classes need to be an edge and a junction 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:
      Metro_Lines (End Point)
      Transfer_Stations (End Point)
      Transfer_Street_Station (End Point)
    Junction Connectivity - Transfer Groups {2}:
      Metro_Entrances (Override) - Transfer Groups {2}
      Metro_Stations (Honor)
  Group 2:
    Edge Connectivity:
      Streets (End Point)
    Junction Connectivity - Transfer Groups {1}:
      Metro_Entrances (Override) - Transfer Groups {1}
Elevation Model: None
Use these connectivity settings when creating EdgeFeatureSource and JunctionFeatureSource objects. See the following code example:
[VB.NET]
' Specify the network dataset's elevation model.
deND.ElevationModel=esriNetworkElevationModel.esriNEMNone

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

' Set the edge feature source's connectivity settings.
Dim edgeFS As IEdgeFeatureSource=CType(streetsNetSource, IEdgeFeatureSource)
With edgeFS
    .UsesSubtypes=False
    .ClassConnectivityGroup=2
    .ClassConnectivityPolicy=esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex
End With

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

' Set the edge feature source's connectivity settings.
edgeFS=CType(metroNetSource, IEdgeFeatureSource)
With edgeFS
    .UsesSubtypes=False
    .ClassConnectivityGroup=1
    .ClassConnectivityPolicy=esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex
End With

' Create a EdgeFeatureSource object and point it to the Transfer_Stations feature class.
Dim tsNetSource As INetworkSource=New EdgeFeatureSource
tsNetSource.Name="Transfer_Stations"
tsNetSource.ElementType=esriNetworkElementType.esriNETEdge

' Set the edge feature source's connectivity settings.
edgeFS=CType(tsNetSource, IEdgeFeatureSource)
With edgeFS
    .UsesSubtypes=False
    .ClassConnectivityGroup=1
    .ClassConnectivityPolicy=esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex
End With

' Create a EdgeFeatureSource object and point it to the Transfer_Street_Station feature class.
Dim tssNetSource As INetworkSource=New EdgeFeatureSource
tssNetSource.Name="Transfer_Street_Station"
tssNetSource.ElementType=esriNetworkElementType.esriNETEdge

' Set the edge feature source's connectivity settings.
edgeFS=CType(tssNetSource, IEdgeFeatureSource)
With edgeFS
    .UsesSubtypes=False
    .ClassConnectivityGroup=1
    .ClassConnectivityPolicy=esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex
End With

' Create a JunctionFeatureSource object and point it to the Metro_Stations feature class.
Dim stationsNetSource As INetworkSource=New JunctionFeatureSource
stationsNetSource.Name="Metro_Stations"
stationsNetSource.ElementType=esriNetworkElementType.esriNETJunction

' Set the junction feature source's connectivity settings.
Dim junctionFS As IJunctionFeatureSource=CType(stationsNetSource, IJunctionFeatureSource)
With junctionFS
    .UsesSubtypes=False
    .RemoveAllClassConnectivityGroups()
    .AddClassConnectivityGroup(1)
    .ClassConnectivityPolicy=esriNetworkJunctionConnectivityPolicy.esriNJCPHonor
End With

' Create a JunctionFeatureSource object and point it to the Metro_Entrances feature class.
Dim entrancesNetSource As INetworkSource=New JunctionFeatureSource
entrancesNetSource.Name="Metro_Entrances"
entrancesNetSource.ElementType=esriNetworkElementType.esriNETJunction

' Set the junction feature source's connectivity settings.
junctionFS=CType(entrancesNetSource, IJunctionFeatureSource)
With junctionFS
    .UsesSubtypes=False
    .RemoveAllClassConnectivityGroups()
    .AddClassConnectivityGroup(1)
    .AddClassConnectivityGroup(2)
    .ClassConnectivityPolicy=esriNetworkJunctionConnectivityPolicy.esriNJCPOverride
End With
[C#]
// Specify the network dataset's elevation model.
deNetworkDataset.ElevationModel=esriNetworkElevationModel.esriNEMNone;

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

// Set the edge feature source's connectivity settings.
streetsEdgeFeatureSource.UsesSubtypes=false;
streetsEdgeFeatureSource.ClassConnectivityGroup=2;
streetsEdgeFeatureSource.ClassConnectivityPolicy =
    esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex;

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

// Set the edge feature source's connectivity settings.
metroLinesEdgeFeatureSource.UsesSubtypes=false;
metroLinesEdgeFeatureSource.ClassConnectivityGroup=1;
metroLinesEdgeFeatureSource.ClassConnectivityPolicy =
    esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex;

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

// Set the edge feature source's connectivity settings.
transferStationsEdgeFeatureSource.UsesSubtypes=false;
transferStationsEdgeFeatureSource.ClassConnectivityGroup=1;
transferStationsEdgeFeatureSource.ClassConnectivityPolicy =
    esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex;

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

// Set the edge feature source's connectivity settings
streetStationsEdgeFeatureSource.UsesSubtypes=false;
streetStationsEdgeFeatureSource.ClassConnectivityGroup=1;
streetStationsEdgeFeatureSource.ClassConnectivityPolicy =
    esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex;

// Create a JunctionFeatureSource object and point it to the Metro_Stations feature class.
IJunctionFeatureSource metroStationsJunctionFeatureSource=new
    JunctionFeatureSourceClass();
INetworkSource metroStationsNetworkSource=(INetworkSource)
    metroStationsJunctionFeatureSource;
metroStationsNetworkSource.Name="Metro_Stations";
metroStationsNetworkSource.ElementType=esriNetworkElementType.esriNETJunction;

// Set the junction feature source's connectivity settings.
metroStationsJunctionFeatureSource.UsesSubtypes=false;
metroStationsJunctionFeatureSource.RemoveAllClassConnectivityGroups();
metroStationsJunctionFeatureSource.AddClassConnectivityGroup(1);
metroStationsJunctionFeatureSource.ClassConnectivityPolicy =
    esriNetworkJunctionConnectivityPolicy.esriNJCPHonor;

// Create a JunctionFeatureSource object and point it to the Metro_Entrances feature class.
IJunctionFeatureSource metroEntrancesJunctionFeatureSource=new
    JunctionFeatureSourceClass();
INetworkSource metroEntrancesNetworkSource=(INetworkSource)
    metroEntrancesJunctionFeatureSource;
metroEntrancesNetworkSource.Name="Metro_Entrances";
metroEntrancesNetworkSource.ElementType=esriNetworkElementType.esriNETJunction;

// Set the junction feature source's connectivity settings.
metroEntrancesJunctionFeatureSource.UsesSubtypes=false;
metroEntrancesJunctionFeatureSource.RemoveAllClassConnectivityGroups();
metroEntrancesJunctionFeatureSource.AddClassConnectivityGroup(1);
metroEntrancesJunctionFeatureSource.AddClassConnectivityGroup(2);
metroEntrancesJunctionFeatureSource.ClassConnectivityPolicy =
    esriNetworkJunctionConnectivityPolicy.esriNJCPOverride;

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:
    Metro_Lines:
      Street Name Fields:
        Primary:
          Name: NAME
    Streets:
      Street Name Fields:
        Primary:
          Name: FULL_NAME
    Transfer_Stations:
      Street Name Fields:
        Primary:
          Name: NAME
The previous settings are the ones to specify and the following code example shows how to implement these settings using ArcObjects:
[VB.NET]
' Create a StreetNameFields object and populate its settings for the Streets source.
Dim snf As IStreetNameFields=New StreetNameFields
With snf
    .Priority=1 'Priority 1 indicates the primary street name.
    .StreetNameFieldName="FULL_NAME"
End With

' Add the StreetNameFields object to a new NetworkSourceDirections object,
' then add it to the EdgeFeatureSource object created earlier.
Dim nsd As INetworkSourceDirections=New NetworkSourceDirections
Dim snfArray As IArray=New ESRI.ArcGIS.esriSystem.Array
snfArray.Add(snf)
nsd.StreetNameFields=snfArray
streetsNetSource.NetworkSourceDirections=nsd

' Create a StreetNameFields object and populate its settings
' for the Metro_Lines and Transfer_Stations sources.
snf=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 objects created earlier.
nsd=New NetworkSourceDirections
snfArray=New ESRI.ArcGIS.esriSystem.Array
snfArray.Add(snf)
nsd.StreetNameFields=snfArray
metroNetSource.NetworkSourceDirections=nsd
tsNetSource.NetworkSourceDirections=nsd
[C#]
// Create a StreetNameFields object and populate its settings for the Streets source.
IStreetNameFields streetNameFields=new StreetNameFieldsClass();
streetNameFields.Priority=1; // Priority 1 indicates the primary street name.
streetNameFields.StreetNameFieldName="FULL_NAME";

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

// Create a StreetNameFields object and populate its settings
// for the Metro_Lines and Transfer_Stations sources.
IStreetNameFields metroStreetNameFields=new StreetNameFieldsClass();
metroStreetNameFields.Priority=1; // Priority 1 indicates the primary street name.
metroStreetNameFields.StreetNameFieldName="NAME";

// Add the StreetNameFields object to a new NetworkSourceDirections object,
// then add it to the EdgeFeatureSource object created earlier.
INetworkSourceDirections metroNetworkSourceDirections=new
    NetworkSourceDirectionsClass();
IArray metroStreetNameFieldsArray=new ArrayClass();
metroStreetNameFieldsArray.Add(metroStreetNameFields);
metroNetworkSourceDirections.StreetNameFields=metroStreetNameFieldsArray;
metroLinesNetworkSource.NetworkSourceDirections=metroNetworkSourceDirections;
transferStationsNetworkSource.NetworkSourceDirections=metroNetworkSourceDirections;
Now that all the source objects 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(streetsNetSource)
    .Add(metroNetSource)
    .Add(tsNetSource)
    .Add(tssNetSource)
    .Add(stationsNetSource)
    .Add(entrancesNetSource)
End With

deND.Sources=sourceArray
[C#]
IArray sourceArray=new ArrayClass();
sourceArray.Add(streetsNetworkSource);
sourceArray.Add(metroLinesNetworkSource);
sourceArray.Add(transferStationsNetworkSource);
sourceArray.Add(streetStationsNetworkSource);
sourceArray.Add(metroStationsNetworkSource);
sourceArray.Add(metroEntrancesNetworkSource);

deNetworkDataset.Sources=sourceArray;

Specifying global turns

The network dataset supports global turns, which will be set on the data element. See the following code example:
[VB.NET]
deND.SupportsTurns=True
[C#]
deNetworkDataset.SupportsTurns=true;

Adding network attributes

The network dataset will be created with five network attributes:
  • Oneway network attribute
  • DriveTime network attribute 
  • Meters network attribute
  • RoadClass network attribute
  • PedestrianTime 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(streetsNetSource, 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(streetsNetSource, 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(streetsNetworkSource,
    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(streetsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue=false; 
    // False means Traversable (that is, not restricted).
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);

DriveTime network attribute

The following is from the New Network Dataset wizard's summary for the DriveTime network attribute:
 DriveTime:
    Usage Type: Cost
    Data Type: Double
    Units Type: Minutes
    Use by Default: True
    Source Attribute Evaluators:
      Metro_Lines (From-To): Constant - -1
      Metro_Lines (To-From): Constant - -1
      Streets (From-To): Field - [FT_Minutes]
      Streets (To-From): Field - [TF_Minutes]
      Transfer_Stations (From-To): Constant - -1
      Transfer_Stations (To-From): Constant - -1
      Transfer_Street_Station (From-To): Constant - -1
      Transfer_Street_Station (To-From): Constant - -1
      Metro_Stations: Constant - -1
    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="DriveTime"
    .UsageType=esriNetworkAttributeUsageType.esriNAUTCost
    .DataType=esriNetworkAttributeDataType.esriNADTDouble
    .Units=esriNetworkAttributeUnits.esriNAUMinutes
    .UseByDefault=True
End With

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

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

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(metroNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(metroNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(tsNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(tsNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(tssNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(tssNetSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized)=CType(netConstEval, INetworkEvaluator)

netConstEval=New NetworkConstantEvaluator
netConstEval.ConstantValue=-1
evalNetAttr.Evaluator(stationsNetSource, esriNetworkEdgeDirection.esriNEDNone)=CType(netConstEval, 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="DriveTime";
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.
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[FT_Minutes]", "");
evalNetAttr.set_Evaluator(streetsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

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

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(metroLinesNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(metroLinesNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(transferStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(transferStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(streetStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(streetStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netConstEval);

netConstEval=new NetworkConstantEvaluatorClass();
netConstEval.ConstantValue= - 1;
evalNetAttr.set_Evaluator(metroStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDNone, (INetworkEvaluator)netConstEval);

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:
      Metro_Lines (From-To): Field - [Meters]
      Metro_Lines (To-From): Field - [Meters]
      Streets (From-To): Field - [Meters]
      Streets (To-From): Field - [Meters]
      Transfer_Stations (From-To): Field - [Shape_Length]
      Transfer_Stations (To-From): Field - [Shape_Length]
      Transfer_Street_Station (From-To): Field - [Shape_Length]
      Transfer_Street_Station (To-From): Field - [Shape_Length]
    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(metroNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

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

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Meters]", "")
evalNetAttr.Evaluator(streetsNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

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

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Shape_Length]", "")
evalNetAttr.Evaluator(tsNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

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

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Shape_Length]", "")
evalNetAttr.Evaluator(tssNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Shape_Length]", "")
evalNetAttr.Evaluator(tssNetSource, 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(metroLinesNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

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

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[Meters]", "");
evalNetAttr.set_Evaluator(streetsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

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

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[Shape_Length]", "");
evalNetAttr.set_Evaluator(transferStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

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

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[Shape_Length]", "");
evalNetAttr.set_Evaluator(streetStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("[Shape_Length]", "");
evalNetAttr.set_Evaluator(streetStationsNetworkSource,
    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
            Select Case UCase([CFCC])
              Case "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19"
                rc=2          'Highway
              Case "A60", "A63"
                rc=3          'Ramp
              Case "A65", "A66", "A68", "A69"
                rc=4          'Ferry
              Case "A62"
                rc=5          'Roundabout
            End Select
          Expression: rc
      Streets (To-From): Field -
          Prelogic:
            rc=1          'Local road
            Select Case UCase([CFCC])
              Case "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19"
                rc=2          'Highway
              Case "A60", "A63"
                rc=3          'Ramp
              Case "A65", "A66", "A68", "A69"
                rc=4          'Ferry
              Case "A62"
                rc=5          'Roundabout
            End Select
          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 & _
                           "Select Case UCase([CFCC])" & vbNewLine & _
                           "  Case ""A10"", ""A11"", ""A12"", ""A13"", ""A14"", ""A15"", ""A16"", ""A17"", ""A18"", ""A19""" & vbNewLine & _
                           "    rc=2          'Highway" & vbNewLine & _
                           "  Case ""A60"", ""A63""" & vbNewLine & _
                           "    rc=3          'Ramp" & vbNewLine & _
                           "  Case ""A65"", ""A66"", ""A68"", ""A69""" & vbNewLine & _
                           "    rc=4          'Ferry" & vbNewLine & _
                           "  Case ""A62""" & vbNewLine & _
                           "    rc=5          'Roundabout" & vbNewLine & _
                           "End Select")
evalNetAttr.Evaluator(streetsNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("rc", _
                           "rc=1 'Local road" & vbNewLine & _
                           "Select Case UCase([CFCC])" & vbNewLine & _
                           " Case ""A10"", ""A11"", ""A12"", ""A13"", ""A14"", ""A15"", ""A16"", ""A17"", ""A18"", ""A19""" & vbNewLine & _
                           " rc=2 'Highway" & vbNewLine & _
                           " Case ""A60"", ""A63""" & vbNewLine & _
                           " rc=3 'Ramp" & vbNewLine & _
                           " Case ""A65"", ""A66"", ""A68"", ""A69""" & vbNewLine & _
                           " rc=4 'Ferry" & vbNewLine & _
                           " Case ""A62""" & vbNewLine & _
                           " rc=5 'Roundabout" & vbNewLine & _
                           "End Select")
evalNetAttr.Evaluator(streetsNetSource, 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" + 
    "Select Case UCase([CFCC])\n\r" + 
    " Case \"A10\", \"A11\", \"A12\", \"A13\", \"A14\", \"A15\", \"A16\", \"A17\", \"A18\", \"A19\"\n\r" + " rc=2 'Highway\n\r" + " Case \"A60\", \"A63\"\n\r" + " rc=3 'Ramp\n\r" + " Case \"A65\", \"A66\", \"A68\", \"A69\"\n\r" + " rc=4 'Ferry\n\r" + " Case \"A62\"\n\r" + " rc=5 'Roundabout\n\r" + "End Select");
evalNetAttr.set_Evaluator(streetsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression("rc", "rc=1 'Local road\n\r" + 
    "Select Case UCase([CFCC])\n\r" + 
    " Case \"A10\", \"A11\", \"A12\", \"A13\", \"A14\", \"A15\", \"A16\", \"A17\", \"A18\", \"A19\"\n\r" + " rc=2 'Highway\n\r" + " Case \"A60\", \"A63\"\n\r" + " rc=3 'Ramp\n\r" + " Case \"A65\", \"A66\", \"A68\", \"A69\"\n\r" + " rc=4 'Ferry\n\r" + " Case \"A62\"\n\r" + " rc=5 'Roundabout\n\r" + "End Select");
evalNetAttr.set_Evaluator(streetsNetworkSource,
    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);

PedestrianTime network attribute

The following is from the New Network Dataset wizard's summary for the PedestrianTime network attribute:
  PedestrianTime:
    Usage Type: Cost
    Data Type: Double
    Units Type: Minutes
    Use by Default: False
    Source Attribute Evaluators:
      Metro_Lines (From-To): Field - [Transittim]
      Metro_Lines (To-From): Field - [Transittim]
      Streets (From-To): Field - [METERS] * 60 / 3000
      Streets (To-From): Field - [METERS] * 60 / 3000
      Transfer_Stations (From-To): Field - [Transittim]
      Transfer_Stations (To-From): Field - [Transittim]
      Transfer_Street_Station (From-To): Field - [Transittim]
      Transfer_Street_Station (To-From): Field - [Transittim]
    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="PedestrianTime"
    .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("[METERS] * 60 / 3000", "")
evalNetAttr.Evaluator(streetsNetSource, esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)
evalNetAttr.Evaluator(streetsNetSource, esriNEDAgainstDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Transittim]", "")
evalNetAttr.Evaluator(metroNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

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

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Transittim]", "")
evalNetAttr.Evaluator(tsNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

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

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Transittim]", "")
evalNetAttr.Evaluator(tssNetSource, esriNetworkEdgeDirection.esriNEDAlongDigitized)=CType(netFieldEval, INetworkEvaluator)

netFieldEval=New NetworkFieldEvaluator
netFieldEval.SetExpression("[Transittim]", "")
evalNetAttr.Evaluator(tssNetSource, 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="PedestrianTime";
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("[METERS] * 60 / 3000", "");
evalNetAttr.set_Evaluator(streetsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);
evalNetAttr.set_Evaluator(streetsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

string transittimField="[Transittim]";
netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression(transittimField, "");
evalNetAttr.set_Evaluator(metroLinesNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression(transittimField, "");
evalNetAttr.set_Evaluator(metroLinesNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression(transittimField, "");
evalNetAttr.set_Evaluator(transferStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression(transittimField, "");
evalNetAttr.set_Evaluator(transferStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)
    netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression(transittimField, "");
evalNetAttr.set_Evaluator(streetStationsNetworkSource,
    esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

netFieldEval=new NetworkFieldEvaluatorClass();
netFieldEval.SetExpression(transittimField, "");
evalNetAttr.set_Evaluator(streetStationsNetworkSource,
    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);
Now that all the attributes have been added to the array, the array can be added to the network dataset element. 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: DriveTime
    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=esriNAUMiles
    .LengthAttributeName="Meters"
    .TimeAttributeName="DriveTime"
    .RoadClassAttributeName="RoadClass"
End With

' 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="DriveTime";
networkDirections.RoadClassAttributeName="RoadClass";

// 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(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 featureDatasetExtension=fdxContainer.FindExtension
    (esriDatasetType.esriDTNetworkDataset);
IDatasetContainer2 datasetContainer2=(IDatasetContainer2)featureDatasetExtension;
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:

About the ArcGIS Network Analyst extension Tutorial
Exercise 2: Creating a multimodal network dataset
What is a network dataset?
Geodatabase




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