Skip to content

Network Node Functions

These functions are used for working with network nodes.

FunctionDescription
addNodeAdds a new node to a project.
deleteNodeDeletes a node from a project.
getNodeIndexGets the index of a node given its ID name.
getNodeIdGets the ID name of a node given its index.
setNodeIdChanges the ID name of a node.
getNodeTypeRetrieves a node’s type given its index.
getNodeValueRetrieves a property value for a node.
setNodeValueSets a property value for a node.
setJunctionDataSets a group of properties for a junction node.
setTankDataSets a group of properties for a tank node.
getCoordinatesGets the (x,y) coordinates of a node.
setCoordinatesSets the (x,y) coordinates of a node.

Adds a new node to a project.

addNode(id: string, nodeType: NodeType): number;

Parameters

ParameterTypeDescription
idstringthe ID name of the node to be added.
nodeTypeNodeTypethe type of node being added (see NodeType)

Returns

Number the index of the newly added node

When a new node is created all of its properties (see NodeProperty) are set to 0.


Deletes a node from a project.

deleteNode(index: number, actionCode: ActionCodeType): void;

Parameters

ParameterTypeDescription
indexnumberthe index of the node to be deleted.
actionCodeActionCodeTypethe action taken if any control contains the node and its links.

If actionCode is ActionCodeType.Unconditional then the node, its incident links and all simple and rule-based controls that contain them are deleted. If set to ActionCodeType.Conditional then the node is not deleted if it or its incident links appear in any controls and error code 261 is returned.


Gets the index of a node given its ID name.

getNodeIndex(id: string): number;

Parameters

ParameterTypeDescription
idstringa node ID name.

Returns

Number the node’s index (starting from 1).


Gets the ID name of a node given its index.

getNodeId(index: number): string;

Parameters

ParameterTypeDescription
indexnumbera node’s index (starting from 1).

Returns

String the node’s ID name.


Changes the ID name of a node.

setNodeId(index: number, newid: string): void;

Parameters

ParameterTypeDescription
indexnumbera node’s index (starting from 1).
newidstringthe new ID name for the node.

Retrieves a node’s type given its index.

getNodeType(index: number): NodeType;

Parameters

ParameterTypeDescription
indexnumbera node’s index (starting from 1).

Returns

NodeType the node’s type (see NodeType).


Retrieves a property value for a node.

getNodeValue(index: number, property: NodeProperty): number;

Parameters

ParameterTypeDescription
indexnumbera node’s index.
propertyNodePropertythe property to retrieve (see NodeProperty).

Returns

Number the current value of the property.

Values are returned in units that depend on the units used for flow rate (see Measurement Units).


Sets a property value for a node.

setNodeValue(index: number, property: NodeProperty, value: number): void;

Parameters

ParameterTypeDescription
indexnumbera node’s index (starting from 1).
propertyNodePropertythe property to set (see NodeProperty).
valuenumberthe new value for the property.

Values are in units that depend on the units used for flow rate (see Measurement Units).


Sets a group of properties for a junction node.

setJunctionData(index: number, elev: number, dmnd: number, dmndpat: string): void;

Parameters

ParameterTypeDescription
indexnumbera junction node’s index (starting from 1).
elevnumberthe value of the junction’s elevation.
dmndnumberthe value of the junction’s primary base demand.
dmndpatstringthe ID name of the demand’s time pattern ("" for no pattern)

These properties have units that depend on the units used for flow rate (see Measurement Units).


Sets a group of properties for a tank node.

setTankData(index: number, elev: number, initlvl: number, minlvl: number, maxlvl: number, diam: number, minvol: number, volcurve: string): void;

Parameters

ParameterTypeDescription
indexnumbera tank node’s index (starting from 1).
elevnumberthe tank’s bottom elevation.
initlvlnumberthe initial water level in the tank.
minlvlnumberthe minimum water level for the tank.
maxlvlnumberthe maximum water level for the tank.
diamnumberthe tank’s diameter (0 if a volume curve is supplied).
minvolnumberthe volume of the tank at its minimum water level.
volcurvestringthe name of the tank’s volume curve ("" for no curve)

These properties have units that depend on the units used for flow rate (see Measurement Units).


Gets the (x,y) coordinates of a node.

getCoordinates(index: number): {
x: number;
y: number;
};

Parameters

ParameterTypeDescription
indexnumbera node index (starting from 1).

Returns

Object

{
x: number;
y: number;
}
PropertyTypeDescription
xnumberthe node’s X-coordinate value.
ynumberthe node’s Y-coordinate value.

Sets the (x,y) coordinates of a node.

setCoordinates(index: number, x: number, y: number): void;

Parameters

ParameterTypeDescription
indexnumbera node index (starting from 1).
xnumberthe node’s X-coordinate value.
ynumberthe node’s Y-coordinate value.