Rebar Class


Represents a rebar element in Autodesk Revit.

Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.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().IntegerValue;
    }

    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().IntegerValue
    End If

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

Inheritance Hierarchy

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

See Also