Location of rebar


#9

It’s not completely straight forward, but have a look here:

In 2017 you could try to feed a list of bar positions to the getcenterlinecurves node


#10

I found another script I had written once, but forgotten about. Think it does what you want:

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

How can we read a rebar set?
Getting all rebar geometry in dynamo
Python Nodes Basics
How to Handle Variable Input List Length/Nesting in Custom Nodes (Python)
#11

Seems like something is wrong with the number of arguments in the GetCenterlineCurves
(still using Revit 2016 btw)


#12

try to remove mpo


#13

perfect !
Now I need to find the intersection of these coordinates with the beam curveline.
The reason I need this is because I’m trying to export the rebar stirrup positions with their (relative to the beam) x coordinates to textfile.


#14

There is off course a simpler way…To determine the distance between the x-coordinates


#15

Is there a way to only list the x coordinates of the first curve of each element ?
Another problem is that this method does not work a set of different stirrups.
It gives me the curves of just one set.


#16

The easiest solution is to create a custom node:


#17

Ok…I’m getting there. Wrote myself a pythonscript to get all the stirrup curve coordinates.
Now I’m trying to get all the separate distances. This might be a stupid question but is there an easy way to calculate the distance between all these points ? As you can see I know how to do it between the first two points, but I need a list of all distances.

Another option might be to extract just the x values from the points and load those into a python script.
Any ideas ?


#18

Solved it !
With a little help from @Einar_Raknes :wink:
Note: This only works on a beam with stirrup rebar. No other rebars.
Next step will be to filter out the stirrups.

Stirrup distances.dyn (11.7 KB)


#19

Removing mpo works, but how can the Python Script take multiple model elements and not a single element?


#20

@Gcf_Design Refer this post @Einar_Raknes has described how to handle list with multiple elements.


#21

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


#22

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


#23

Kulkul,

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


#24

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?


#25

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


#27

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?


#28

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


#29

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