Get rebar geometry in Dynamo

Hey @Tholm_MTH
In researching I came across the post below. Within this post @Einar_Raknes provided a way to get the curve of the rebar. You don’t get the actual geometry of the rebar, but if you get the solid geometry of the element, you should be able to use the Geometry.DoesIntersect node to verify if the curve intersects the solid.

My test


Code from python script

import clr

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

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

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

doc = DocumentManager.Instance.CurrentDBDocument
view = doc.ActiveView

#Convert input from dynamo to revit
rebar = UnwrapElement(IN[0])

#Set options
mpo = MultiplanarOption.IncludeAllMultiplanarCurves

#Get info from rebar
numOfBars = rebar.NumberOfBarPositions
quantity = rebar.Quantity
layoutRule = rebar.LayoutRule

if numOfBars > 1:
	#Find visible bars and get their centerline curves transformed to correct position
	centerlineCurves = []
	for i in range(numOfBars):
		if not rebar.IsBarHidden(view,i):
			posTransform = rebar.GetBarPositionTransform(i)
			revitCurve = [c.CreateTransformed(posTransform) for c in rebar.GetCenterlineCurves(0,0,0,mpo,0)]
			centerlineCurves.append([r.ToProtoType(True) for r in revitCurve])
	
else:
	centerlineCurves = [r.ToProtoType(True) for r in rebar.GetCenterlineCurves(0,0,0,mpo,0)]
OUT = centerlineCurves
1 Like