Rebar Class


Represents a rebar element in Autodesk Revit.

Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 23.0.0.0 (23.1.0.0)
Since: 2009

Syntax

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

Examples

Copy C#
private void Getinfo_Rebar(Rebar rebar)
{
    string message = "Rebar: ";
    //get the bar type of the rebar
    message += "\nBar Type: " + (rebar.Document.GetElement(rebar.GetTypeId()) as RebarBarType).Name;

    //get the curve information
    IList<Curve> curves = rebar.GetCenterlineCurves(false, false, false, MultiplanarOption.IncludeOnlyPlanarCurves, 0);
    message += "\n\nThe Curves property has " + curves.Count + " curves:";
    foreach (Curve curve in curves)
    {
        // Get curve start point
        message += "\nCurve start point:(" + curve.GetEndPoint(0).X + ", "
            + curve.GetEndPoint(0).Y + ", " + curve.GetEndPoint(0).Z + ")";
        // Get curve end point
        message += "; Curve end point:(" + curve.GetEndPoint(1).X + ", "
            + curve.GetEndPoint(1).Y + ", " + curve.GetEndPoint(1).Z + ")";
    }

    //get the host element of the rebar
    if (null != rebar.Document.GetElement(rebar.GetHostId())) //maybe some rebars don't have host
    {
        message += "\n\nThe host element ID : " + rebar.GetHostId().ToString();
    }

    TaskDialog.Show("Revit", message);
}
Copy VB.NET
Private Sub Getinfo_Rebar(rebar As Rebar)
    Dim message As String = "Rebar: "
    'get the bar type of the rebar
    message += vbLf & "Bar Type: " + TryCast(rebar.Document.GetElement(rebar.GetTypeId()), RebarBarType).Name

 'get the curve information
 Dim curves As IList(Of Curve) = rebar.GetCenterlineCurves(False, False, False, MultiplanarOption.IncludeOnlyPlanarCurves, 0)
 message += vbLf & vbLf & "The Curves property has " & curves.Count & " curves:"
    For Each curve As Curve In curves
        ' Get curve start point
        message += ((vbLf & "Curve start point:(" + curve.GetEndPoint(0).X & ", ") + curve.GetEndPoint(0).Y & ", ") + curve.GetEndPoint(0).Z & ")"
        ' Get curve end point
        message += (("; Curve end point:(" + curve.GetEndPoint(1).X & ", ") + curve.GetEndPoint(1).Y & ", ") + curve.GetEndPoint(1).Z & ")"
    Next

    'get the host element of the rebar
    If rebar.Document.GetElement(rebar.GetHostId()) IsNot Nothing Then
        'maybe some rebars don't have host
        message += vbLf & vbLf & "The host element ID : " + rebar.GetHostId().ToString()
    End If

    TaskDialog.Show("Revit", message)
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Element
Autodesk.Revit.DB.Structure Rebar

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 →