Finding Pipe Lengths



I have created a pipe network but have forgotten to turn on Auto-Length for the majority of my pipes. How can I get these pipe lengths estimated without having to redraw each pipe?


you do not need to draw again, use Epanet to edit the lengths and others. Or you can also edit in the text file with INP format


How do I get it to estimate the pipe length if I do not know its length?


Hi @mikebernal21, you can use EPANET-MATLAB Toolkit:

like this:

clear all; close all;

% Load paths

% Load file
d = epanet('test.inp');

% Get link node indices # from node to node
indices = d.getLinkNodesIndex;

% Return initial length of pipes

% Fixed length of pipes
for link_ind = 1:d.LinkCount
    ind_Node1 = indices(link_ind, 1);
    ind_Node2 = indices(link_ind, 2);
    [latlons] = d.getNodeCoordinates([ind_Node1, ind_Node2]);
    X = [latlons(1, :);latlons(2, :)];
    fixLength = pdist(X, 'euclidean');
    d.setLinkLength(link_ind, fixLength);

% Rerurn link lengths


% Unload dll


or with executable:



Thanks everyone, but I found an easier way for those like myself who do not like/understand coding very much. I found that if I have Auto-Length on, and I move each junction from one spot back to the original spot, each connected pipe will have its length automatically estimated.