How Revit calculate rebar Bar Length parameter

Hi all, @c.poupin @christian.stan

In my main script, which creates longitudinal beam rebars from a straight curve, the resulting shape is L-shaped (a hook type Standard - 90 deg. is added to one end of the bar to form the L-shape). I need to ensure that the Bar Length parameter in the Rebar Properties does not exceed 12.00 m.

Based on the formula I retrieved from the Rebar Shape Parameters related to Shape 11, which defines the bar length calculation , I used Excel to verify the bar length for the two rebar shapes shown in the image below:

  • The top rebar was created directly by selecting Shape 11 from the Rebar Shape Browser.
  • The bottom rebar was first created by selecting Shape 00 from the Rebar Shape Browser, then a hook was added to one end, after which Revit automatically generated a new shape named Forme d’armature1.

However, the bar length I calculated in Excel is slightly different from the one displayed in the Rebar Properties. I’m a bit confused about how Revit calculates this parameter.

formula used to calculate Bar Length:
image

Here my tested code:

import clr
import sys
import System
from System.Collections.Generic import IList, List
from System import Array
# ProtoGeometry
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Revit API
clr.AddReference('RevitAPI')
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

# Revit Nodes
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

# Revit Services
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# System.Core
clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)
import functools
# -------------------------------------------------------------
# Rebar cover management utilities
# -------------------------------------------------------------

rebar_types = (
    FilteredElementCollector(doc)
    .OfCategory(BuiltInCategory.OST_Rebar)
    .WhereElementIsElementType()
    .WherePasses(ElementClassFilter(RebarBarType))
    .ToElements()
)

top_bar_type = next((r for r in rebar_types if r.LookupParameter('DiamĆØtre de barre').AsValueString() == "10 mm"), None)


hook_types = list(FilteredElementCollector(doc).OfClass(RebarHookType).ToElements())

standard_hook_types = [hk for hk in hook_types if hk.Style == RebarStyle.Standard]

hook_90 = next((h for h in standard_hook_types if Element.Name.GetValue(h) == "Standard - 90 deg."), None)

def rebar_bar_length(bartype, hooktype, a):
    bar_diameter = bartype.BarModelDiameter
    
    hook_bend_diameter = bartype.StandardHookBendDiameter
    
    standard_bend_diameter = bartype.StandardBendDiameter
    
    hook_extention_multuplier = hooktype.StraightLineMultiplier
    
    hook_length_extention = hooktype.GetHookExtensionLength(bartype)
    
    b = hook_length_extention + hook_bend_diameter/2 + bar_diameter
    
    bar_length = a / 304.8 + b - 0.5*standard_bend_diameter/2 - bar_diameter
    return bar_length * 304.8
    
OUT = rebar_bar_length(top_bar_type, hook_90, 10000)

Any help would be apreciated.
Thanks.

Hi,

I don’t know how Revit calculates the length exactly but the below command may be useful, I think it could be run once your script has added the bars.

Help | Splice Rebar - By Length | Autodesk

1 Like

I did see your question on the Revit structures forum as well, have you tried using the Rebar families that come with Revit 2025 or 26? The length calculation is done within the family, the Structural Rebar family you are using may have been corrected or it could apply to a certain country?

1 Like

@Mike.Buttery

Do you have a response to this question?

Thanks

Check you hook length and bend diameters as this will drive the standard bar length vs the shape

Rebar Hook Length Parameters

2 Likes

@Mike.Buttery

Of course. As you can see in the image below, I made sure to enter the same parameters in my code to reproduce the same results. However, the Bar Length displayed in Revit is completely different from my output, so I’m a bit confused and I don’t know how Revit internally computes this parameter ?

Note: You can verify the accuracy of my results yourself by testing my code above.

Thanks.

Revit calculates the centreline length of the bar and the standard hook bend radius is used.
here’s an exact formula to calculate the length : R is std hook bend radius.

2 Likes

The standard shape 11 formula will give you an approximate length of the bar (if you had used hook bend dia) 10000+210 - 25 - 10 = 10175.

1 Like

Set your hook bend diameter to 150mm

You have a hook attached to a standard L bar (2 segments) which may be adding length

Change the detail level to fine to get the fully rendered bar

You should be getting 10165.7 (10176.4 is hook bend dia 100 [10210 - 120 + 86.4])

Standard straight bar with 90° hook


ā€˜L’ bar with two segments no hooks

1 Like

Thanks a lot @rajeshjamariya16 for your reply

The formula you provided (which is exactly what I was looking for) gives the same value for the Bar Length displayed by Revit in my example for the generated shape Forme d’armature 1.
I understand now that Revit calculates this value by retrieving the centreline length of the bar.

My question is: can you provide me with a link to the Revit documentation that explains how the centreline length of a rebar is calculated, and how I can retrieve it programmatically using Dynamo?

Thanks.

1 Like

Here’s two ways documented and available from the API

import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *


def from_internal(n, units=None):
    if units is None:
        units = (
            doc.GetUnits()
            .GetFormatOptions(SpecTypeId.Length)
            .GetUnitTypeId()
        )
    return UnitUtils.ConvertFromInternalUnits(n, units)


doc = DocumentManager.Instance.CurrentDBDocument

rebars = FilteredElementCollector(doc).OfClass(Structure.Rebar).ToElements()

mpo = Structure.MultiplanarOption.IncludeAllMultiplanarCurves

bip = BuiltInParameter.REBAR_ELEM_LENGTH

curves = rebars[0].GetCenterlineCurves(True, False, False, mpo, 0)

OUT = (
    from_internal(sum(c.Length for c in curves)),
    from_internal(rebars[0].get_Parameter(bip).AsDouble()),
)
3 Likes

@Mike.Buttery

Your code return the expected value for Bar Length as it’s displayed in the rebar properties shown in the image below.
However I still have another question as I explained in the image, so please response me

Thanks.

The ā€œLength of each barā€ looks like a calculated parameter - without the formula I can’t really comment

I would suggest to do some trial and error testing to see what changes the value and work out what is affecting the length

1 Like

As Mike mentioned, ā€œLength of each barā€ looks like a calculated parameter (not revit default, someone could have added it)
The formula seems to be standard : A + B + C - r -2d = 9983.7 + 800 + 600 - 75 - 20 = 11288.7mm

ā€Bar Lengthā€ and ā€œTotal Bar Lengthā€ are revit parameters.

2 Likes

@Mike.Buttery

You misunderstood me… I’m not talking about the calculation of ā€œLength of each barā€, which depends on each shape and may change when the shape changes.

As @rajeshjamariya16 mentioned, even though ā€œBar Lengthā€ is a Revit parameter (and I assume it is the basis for calculating ā€œTotal Bar Lengthā€ by multiplying it by the number of bars), Revit uses the rounded value of ā€œLength of each barā€ (which is 11 290 mm) instead of the actual rounded value of ā€œBar Lengthā€ (which is 11 295 mm).

So my question is: Which rule or parameter does Revit use to decide the final value of ā€œBar Lengthā€ that is then used to compute ā€œTotal Bar Lengthā€?

Thanks.

See the documentation: Reinforcement Rounding

2 Likes

It’s because of reinforcement rounding. If you want to use original length, just disable it.

1 Like

It’s now clear to me how Revit adjusts the Bar Length and Length of each bar based on the reinforcement rounding settings.

As you can see in the image below, and based on the guidance from @rajeshjamariya16 and @Mike.Buttery, I was finally able to solve my issue and create an L-shape rebar with the desired Bar Length (equal to 12.0 m) by applying the following code

Rebar _L_shape
import clr
import sys
import System
import math
from System.Collections.Generic import IList, List

clr.AddReference('RevitAPI')
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)

rebar_types = (FilteredElementCollector(doc)\
                .OfClass(RebarBarType)\
                .ToElements())

bar_type = next((r for r in rebar_types if r.LookupParameter('DiamĆØtre de barre').AsValueString() == "10 mm"), None)

hook_types = list(FilteredElementCollector(doc).OfClass(RebarHookType).ToElements())

hook_90 = next((h for h in hook_types if Element.Name.GetValue(h) == "Standard - 90 deg."), None)


def from_internal(n, units=None):
    if units is None:
        units = (
            doc.GetUnits()
            .GetFormatOptions(SpecTypeId.Length)
            .GetUnitTypeId()
        )
    return UnitUtils.ConvertFromInternalUnits(n, units)


def create_L_rebar_shape(beam, bartype, hook_type, cover):
    
    width = beam.Symbol.LookupParameter('b').AsDouble()
    d = bartype.BarModelDiameter 
    D = bartype.StandardHookBendDiameter 
    l = hook_type.GetHookExtensionLength(bartype) 
    b = l + D/2 + d
    c = cover/0.3048
    a = (12 / 0.3048) - b - ((D + d) * math.pi /4) + D + 2 * d
    
    L = beam.Location.Curve.Length
    start_pt = beam.Location.Curve.GetEndPoint(0)
    end_pt = beam.Location.Curve.Evaluate(a/L, True)
    curve = Line.CreateBound(start_pt, end_pt)
    curve = curve.CreateTransformed(Transform.CreateTranslation(XYZ(0,-1,0).Multiply(width/2 - c).Add(XYZ(0,0,-1).Multiply(c)).Add(XYZ(1,0,0).Multiply(c))))
    
    return curve

rebars = FilteredElementCollector(doc).OfClass(Structure.Rebar).ToElements()

mpo = Structure.MultiplanarOption.IncludeAllMultiplanarCurves

bip = BuiltInParameter.REBAR_ELEM_LENGTH



beams = FilteredElementCollector(doc)\
    .OfCategory(BuiltInCategory.OST_StructuralFraming)\
    .WhereElementIsNotElementType()\
    .Where(System.Func[DB.Element, System.Boolean](lambda b: b.StructuralUsage == StructuralInstanceUsage.Girder))\
    .ToList()
    
with Transaction (doc, 'create rebar') as t:
    t.Start()
    beam = beams[0]
    width = beam.Symbol.LookupParameter('b').AsDouble()
    curve = create_L_rebar_shape(beam, bar_type, hook_90, 0.05)
    rebar_curve = List[Curve]()
    rebar_curve.Add(curve)
    rebar = Rebar.CreateFromCurves(
        doc,
        RebarStyle.Standard,
        bar_type,
        hook_90,
        None,
        beam,
        XYZ(0, 1, 0),
        rebar_curve,
        RebarHookOrientation.Left,
        RebarHookOrientation.Left,
        True, True
    )
    rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(3, width-2*0.05, True, True, True)
    #doc.Regenerate()
    t.Commit()

curves = rebar.GetCenterlineCurves(True, False, False, mpo, 0)    
OUT = (
    from_internal(sum(c.Length for c in curves)*1000),
    from_internal(rebar.get_Parameter(bip).AsDouble()*1000),
)```

Thanks.

1 Like