Segment Class


This element represents a segment of an MEP curve object.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 16.0.0.0 (16.0.0.0)
Since: 2013

Syntax

C#
public class Segment : Element
Visual Basic
Public Class Segment _
	Inherits Element
Visual C++
public ref class Segment : public Element

Remarks

Currently, only pipe curves can be broken into separate segment elements.

Examples

Copy C#
private void GetPipeSegmentSizesFromDocument(Document document)
{
    FilteredElementCollector collectorPipeType = new FilteredElementCollector(document);
    collectorPipeType.OfClass(typeof(Segment));

    IEnumerable<Segment> segments = collectorPipeType.ToElements().Cast<Segment>();
    foreach (Segment segment in segments)
    {
        StringBuilder strPipeInfo = new StringBuilder();
        strPipeInfo.AppendLine("Segment: " + segment.Name);

        strPipeInfo.AppendLine("Roughness: " + segment.Roughness);

        strPipeInfo.AppendLine("Pipe Sizes:");
        double dLengthFac = 304.8;  // used to convert stored units from ft to mm for display
        foreach (MEPSize size in segment.GetSizes())
        {
            strPipeInfo.AppendLine(string.Format("Nominal: {0:F3}, ID: {1:F3}, OD: {2:F3}",
                                        size.NominalDiameter * dLengthFac, size.InnerDiameter * dLengthFac, size.OuterDiameter * dLengthFac));
        }


        TaskDialog.Show("PipeSetting Data", strPipeInfo.ToString());
        break;
    }
}
Copy VB.NET
Private Sub GetPipeSegmentSizesFromDocument(document As Document)
    Dim collectorPipeType As New FilteredElementCollector(document)
    collectorPipeType.OfClass(GetType(Segment))

    Dim segments As IEnumerable(Of Segment) = collectorPipeType.ToElements().Cast(Of Segment)()
    For Each segment As Segment In segments
        Dim strPipeInfo As New StringBuilder()
        strPipeInfo.AppendLine("Segment: " + segment.Name)

        strPipeInfo.AppendLine("Roughness: " + segment.Roughness)

        strPipeInfo.AppendLine("Pipe Sizes:")
        Dim dLengthFac As Double = 304.8
        ' used to convert stored units from ft to mm for display
        For Each size As MEPSize In segment.GetSizes()
            strPipeInfo.AppendLine(String.Format("Nominal: {0:F3}, ID: {1:F3}, OD: {2:F3}", size.NominalDiameter * dLengthFac, size.InnerDiameter * dLengthFac, size.OuterDiameter * dLengthFac))
        Next


        TaskDialog.Show("PipeSetting Data", strPipeInfo.ToString())
        Exit For
    Next
End Sub

Inheritance Hierarchy

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →