Location of rebar

Kulkul,

Many thanks for this.

I am a Dynamo novice really. Managed to create and manipulate a few scripts, but what is outlined is beyond me.

I wouldn’t know how to amend the following script to accept multiple elements:

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,0)]
centerlineCurves.append([r.ToProtoType(True) for r in revitCurve])

else:
centerlineCurves = [r.ToProtoType(True) for r in rebar.GetCenterlineCurves(0,0,0,0)]
OUT = centerlineCurves

@Gcf_Design Use this custom node Rebar.GetCentreLine.dyf (3.4 KB) with lacing to longest for multiple elements.

2 Likes

Kulkul,

I have tried using the nodes below, with different lacing, yet l have never got them to work. Do you have any ideas?

Kulkul,

I have filtered out rebar with lengths greater than 6m via a mask, then tried to pass rebar that exceed 6m into your node with longest lacing, yet it returns null.

Any thoughts why?

@Gcf_Design You should connect elements list to filterbybool mask node currently your connecting values.

1 Like

With your kind assistance l am getting there l think.

So l have filtered out the centrelines of the rebar which exceed 6m, and l am then attempting to pass through the split curve with overlap node, yet null is being returned.

Dare l ask, any thoughts?

Rebar by curve still says NULL, what is the issue with the lines / curves?

Updated for 2019:

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])
rebarShp = rebar.GetShapeDrivenAccessor()

#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 = rebarShp.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


@jostein_olsen Do you have any suggestion to use this python code block for other rebar which are not shape driven?

Hi @d.kelfkens. Did you get how to make an opening in a rebar set?

4 posts were split to a new topic: Get Rebar Centerlines Revit 2021