BIM World
A Professional BIM Learning Platform


Revit API: Converting Pipe Fittings for Accurate Pipeline Length Calculation

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());
xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » Revit API: Converting Pipe Fittings for Accurate Pipeline Length Calculation

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up