Get Individual Rebar Length in a Rebar Set

Greetings everyone.

Is it possible for us to get the individual length for each rebar in a rebar set? When I select the element using the select model element node or select all elements by category, the rebar length would be varies. And Dynamo will return an empty value.

rebar set length

I want to get the individual length like in the Revit schedule. Not as a rebar set.

Thanks in advance.

Hi Edwin, welcome!

Are you able to show what you have tried in Dynamo?

Have a look at this post which is a good guide for new members
https://forum.dynamobim.com/t/how-to-get-help-on-the-dynamo-forums

This is what I have so far. The graph shows the rebar length except when the rebar length varies in a rebar set.

I think you will find the rebar containers are empty. Here is a graph which can filter out the containers and get quantity and total length


code for string - let me know if there are any containers with any items

"rc = UnwrapElement(IN[0])
OUT = [r.ItemsCount for r in rc]";

Hi Mike,

Interesting. I don’t have RebarContainer like you have. I can’t upload my Revit file as I’m a new member, but if you are interested in reviewing the file, you can download it from my OneDrive (Revit 2024 file version).

I found a workaround by creating a rebar schedule that lists all the rebar and then grabs the value using Schedule.GetDataColumn node from Bimorph package. I prefer to select the elements directly, though, if anyone has a solution.

Thank you very much for helping me Mike.

Worked it out. ‘Bar Length’ only returns a value when all of the bars are the same length. There are the ‘Maximum bar length’ or the ‘Minimum bar length’ parameters however I used the ‘Total Bar Length’ / ‘Quantity’ to get the average bar length. Here is the graph

Much appreciated, Mike.
However, it’s not applicable to my case. The rebar lengths are not typical. I isolate one of them as example.

rebar set

Looking into it - it’s going to be a bit of work and will not be able to be done with standard nodes. Unfortunately the Dynamo Rebar packages I have tried have not been updated to recent API changes so they are not currently working
The individual geometry can be accessed, however it’s broken into arcs and lines so we need to group those into bars to get individual lengths - example below
image

What do you need the length of every bar for?

Here’s how I have been able to get the length of every bar in a Rebar set - I have not checked if this is accurate - please check that this suits your needs and is correct

Code for python node

import clr

clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

clr.AddReference("RevitAPI")

from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *


def geomfilter(revitgeom):
    return isinstance(revitgeom, (Line, Arc))


doc = DocumentManager.Instance.CurrentDBDocument

# Helper utils
to_dstype = Revit.GeometryConversion.GeometryObjectConverter.Convert

# Set view to Medium to get lines and arcs
currentdetaillevel = doc.ActiveView.DetailLevel

TransactionManager.Instance.EnsureInTransaction(doc)
doc.ActiveView.DetailLevel = ViewDetailLevel.Medium
TransactionManager.Instance.TransactionTaskDone()

# View options
options = Options()
options.ComputeReferences = True
# options.IncludeNonVisibleObjects = True
options.View = doc.ActiveView

collector = (
    FilteredElementCollector(doc)
    .OfClass(Rebar)
    .WhereElementIsNotElementType()
    .ToElements()
)

rebar_geom = [rebar.get_Geometry(options) for rebar in collector]

OUT = collector, [[to_dstype(g) for g in rb if geomfilter(g)] for rb in rebar_geom]

# Return view to original detail level
TransactionManager.Instance.EnsureInTransaction(doc)
doc.ActiveView.DetailLevel = currentdetaillevel
TransactionManager.Instance.TransactionTaskDone()

Hi Mike,
Thank you very much! It works like a charm. I checked the schedule and the Dynamo parameters. It gives the correct value.
Much appreciated!

I want to create a script to calculate the required bar for fabrication. If the remaining bar in the shop is long enough, I want to check if I can use them for the next production. Basically, I want to minimize the waste for the precast production.

Thanks again, Mike!

1 Like

Ahh - that makes perfect sense!
Look here for ideas on minimising waste - Cutting stock problem

Thanks for the reference, Mike.
That 1D problem is what I’m trying to do.