Collect rebars along wall face

Hi Guys!

Im trying to group rebars which are closer to the “Exterior” or the “interior” faces of the walls. I have developed a simple script shown below which uses the concept of surface thickening and using geometry intersect option to group them.

The problem with this is that, the thickened surface also comes into contact with the perpendicular walls, which messes up the process where there are “T” junctions in the model.

Is there a way to just thicken one side of the surface instead of both the sides. My ultimate aim is to isolate 2 layers of rebars in one side of the wall, so that i can apply some parameters to them.

Any help would be great!

Another picture to show the exact issue:

Don’t completely flatten your list - use sublists instead and only test the groups of rebar against the groups of surfaces.

Also, you may want to use Geometry.DistanceTo instead of bounding box containment.

In each sublist:
Get the distance from rebar to interior face.
Get the distance from rebar to exterior face.
If D1 > D2 the rebar is should get an “interior” key, otherwise the rebar should get an “exterior” key.
Group the rebars by the ‘interior/exterior keys.

1 Like

Thanks a lot for the quick reply. Using Geometry.DistanceTo node does sound good. But i faced a bit of a dead end when i tried it. Its just that whenever i try to convert the rebar elements to Geometry using Element.Geometry, i just get an empty list. Even tried it without using Levels.

Is there a workaround?

Hi @Dynamo_Noob

You can get Rebar Centerline Geometry this way:

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

ProcessLists = lambda function, lists: [ProcessLists(function, item) if isinstance(item, list) else function(item) for item in lists]
ApplyFunction = lambda func, objs: ProcessLists(func, objs) if isinstance(objs, list) else [func(objs)]

def Unwrap(item):
    return UnwrapElement(item)
if isinstance(IN[0], list):
	rebar = ProcessLists(Unwrap, IN[0])
	rebar = Unwrap(IN[0])

def task(rc):
	return [r.ToProtoType(True) for r in rc.GetCenterlineCurves(0,0,0,MultiplanarOption.IncludeAllMultiplanarCurves,0)]

OUT = ApplyFunction(task,rebar)

Hi @Kulkul

Sorry for the late reply. I tried using the python script and had the following warning:


But, by any chance, is this similar to “Rebar.GetCenterlineCurve” node from BIM4Struc package?

This works! i had not connected the node to the rebars. Im a Python Noob too!

Will test this one out and see how it goes!

Hi again @JacobSmall

Loos like the keys are a bit complex since, there will be four values for each of the rebars in one wall and the same process for several other walls against several other rebars which increases the conditions two fold. Im currently struggling to match the rebars with their respective walls, which i think will make the task a bit more simpler and also, it seems like the script needs a better list management. I’ve only gotten this far with the script:

Any pointers will be greatly appreciated. @Kulkul Please feel free to pitch in :slight_smile:

Could you drop rvt file here?

1 Like

I’ve attached the test Revit file and also the script.

Rebar Test.rvt (2.4 MB)

Assign Rebar Class.dyn (118.8 KB)

Any pointers? @Kulkul

I’m currently away from my pc. Will get back to you soon.


Hi @Dynamo_Noob

This will get you closest Rebar to your Surfaces:


hi @Kulkul

Thanks a lot for following up!! i’ll look into how this works in getting the rebars at respective faces. And will post the script here too when I’m successful!