Adds a weight to an existing the geometric network, features are not changed in this process.
[Visual Basic .NET] Public Sub AddWeightToNetwork ( _ ByVal GeometricNetwork As IGeometricNetwork, _ ByVal weightName As String, _ ByVal weightType As esriWeightType, _ ByVal bitGateSize As Integer, _ ByVal weightAssociations As ISet _ )
[C#] public void AddWeightToNetwork ( IGeometricNetwork GeometricNetwork, string weightName, esriWeightType weightType, int bitGateSize, ISet weightAssociations );
[C++]
HRESULT AddWeightToNetwork(
IGeometricNetwork* GeometricNetwork,
BSTR weightName,
esriWeightType weightType,
long bitGateSize,
ISet* weightAssociations
);
[C++]Parameters
GeometricNetwork [in]GeometricNetwork is a parameter of type IGeometricNetwork
weightName [in] weightName is a parameter of type BSTR weightType [in]weightType is a parameter of type esriWeightType
bitGateSize [in] bitGateSize is a parameter of type long weightAssociations [in]weightAssociations is a parameter of type ISet
Product Availability
Remarks
The AddWeightToNetwork method will add a weight to the geometric network with the specified name and the type. Additionally, the weight associations will be created for all feature class and field pairings that are specified in the weightAssociations parameter.
The weightAssociations parameter is a set of StringPair objects. A StringPair is a set of strings where the first string represents the class name, the second the field name. Both must be supplied for the StringPair to be valid. Fully qualified strings are supported.
When specifying a weightType not of type esriWTBitGate, set the bitGateSize parameter to 0.
If the network is on SDE and is versioned, the addition of the weight will be reflected across all versions of the geometric network. The AddWeightToNetwork method will not act upon the features in the network, no snapping will occur and no orphan junction features will be created.
Weights cannot be specified under the following circumstances:
~ for any field on the orphan junction feature class
~ for either the Enabled or Ancillary Role fields
~ for any field that is already associated with a weight
An exclusive schema lock must be obtained before using the AddWeightToNetwork method. See the ISchemaLock interface for information on listing existing schema locks and obtaining an exclusive schema lock.
The following code can be used to add a weight of type Integer to a geometric network:
public void esriNetworkAnalysis__INetworkBuilder2__AddWeightToNetwork(IGeometricNetwork geometricNetwork, string weightName, string featureclassName, string weightfieldName)
{
INetworkBuilder2 networkBuilder2 = new NetworkLoaderClass() as INetworkBuilder2;
ESRI.ArcGIS.esriSystem.ISet weightSet = new ESRI.ArcGIS.esriSystem.SetClass();
IStringPair stringPair = new StringPairClass();
// Assign the feature class and field for the weight and add them to the Set
stringPair.FirstString = featureclassName;
stringPair.SecondString = weightfieldName;
weightSet.Add(stringPair);
// Add the weight to the network
networkBuilder2.AddWeightToNetwork(geometricNetwork, weightName, esriWeightType.esriWTInteger, 0, weightSet);
}
The following code can be used to add a weight of type Integer to a geometric network:
Public Sub esriNetworkAnalysis__INetworkBuilder2__AddWeightToNetwork(geometricNetwork As IGeometricNetwork, weightName As String, featureclassName As String, weightfieldName As String)
Dim networkBuilder2 As INetworkBuilder2 = CType(New NetworkLoader, INetworkBuilder2)
Dim weightSet As ESRI.ArcGIS.esriSystem.ISet = New ESRI.ArcGIS.esriSystem.Set
Dim stringPair As IStringPair = New StringPair
' Assign the feature class and field for the weight and add them to the Set
stringPair.FirstString = featureclassName
stringPair.SecondString = weightfieldName
weightSet.Add(stringPair)
' Add the weight to the network
networkBuilder2.AddWeightToNetwork(geometricNetwork, weightName, esriWeightType.esriWTInteger, 0, weightSet)
End Sub