In Revit, the pipeline length calculated represents the actual length of the pipe itself. In contrast, traditional calculations also account for the length added by pipe fittings. Although Revit’s measurement is theoretically more accurate, if you want to follow traditional calculation methods, Revit can automatically convert the length of pipe fittings into the total pipeline length.
The conversion logic is straightforward. First, retrieve the pipeline and check if any fittings are connected to its connectors. If fittings are connected, calculate the distance from the connector to the fitting’s family insertion point. This distance is then added to the pipeline length to get the converted total length.
It’s important to note that this conversion depends on the position points of the fitting families. For example, built-in standard fittings like elbows and tees work well for length conversion because their position points are located at the pipe intersections. However, fittings like reducers convert the length only to one end since their position point is located at one of the connectors.
The following C# code demonstrates this approach:
// Get the pipeline length
double pipeLength = pipe.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
// Initialize converted length with the pipe length
double convertLength = pipeLength;
foreach (Connector con in pipe.ConnectorManager.Connectors)
{
if (con.IsConnected)
{
foreach (Connector ref_con in con.AllRefs)
{
if ((BuiltInCategory)ref_con.Owner.Category.Id.IntegerValue == BuiltInCategory.OST_PipeFitting &&
(ref_con.ConnectorType == ConnectorType.End || ref_con.ConnectorType == ConnectorType.Curve || ref_con.ConnectorType == ConnectorType.Physical))
{
convertLength += con.Origin.DistanceTo((ref_con.Owner.Location as LocationPoint).Point);
break;
}
}
}
}
// Display the original and converted lengths in millimeters
TaskDialog.Show("goodwish",
Math.Round(UnitUtils.ConvertFromInternalUnits(pipeLength, DisplayUnitType.DUT_MILLIMETERS), 3).ToString() +
" => " +
Math.Round(UnitUtils.ConvertFromInternalUnits(convertLength, DisplayUnitType.DUT_MILLIMETERS), 3).ToString());













Must log in before commenting!
Sign Up