Rebar.SetLayout does not work Revit 2019

Hi guys, I am having problems using the node Rebar.SetLayoutAsMaximumSpacing in Revit 2019. It works fine in Revit 2018 but when i try the same code on 2019 version of Revit it does not work. Does anyone know why this is happening?

2 Likes

I’m having the same issue. The node is not doing anything. I checked the node code and everything seems to be fine, so I don’t know what the problem could be.

It’s because of an API change, the set spacing methods are moved to the RebarShapeDrivenAccessor class. In your code you need an addition step, GetShapeDrivenAccessor() from your Rebar.

http://www.revitapidocs.com/2019/c77085bd-db18-4869-bb2a-1e5c702e273a.

sda = rebar.GetShapeDrivenAccessor()
sda.SetLayoutAsMaximumSpacing(numberOfBarPositions, arrayLength, barsOnNormalSide, includeFirstBar, includeLastBar)
3 Likes

It worked! Thank you very much. I’ll just copy the entire syntax if anyone has any trouble knowing where to put it.

#Preparing input from dynamo to revit
rebarElement = UnwrapElement(IN[0])
spacing = IN[1]
arrayLength = IN[2]
barsOnNormalSide = IN[3]
includeFirstBar=IN[4]
includeLastBar=IN[5]

#convert from mm to feet:
if IN[6]:
	spacing = spacing/304.8
	arrayLength = arrayLength/304.8

#Change rebar in transaction
TransactionManager.Instance.EnsureInTransaction(doc)
sda = rebarElement.GetShapeDrivenAccessor()
sda.SetLayoutAsMaximumSpacing(spacing, arrayLength, barsOnNormalSide, includeFirstBar, includeLastBar)
TransactionManager.Instance.TransactionTaskDone()

I was not being able to run it because the parameter names in my node were not the same.

Now with that tweak works :slight_smile:

6 Likes

By the way: There is a node for setting maximum spacing in the Dynamo for Rebar package.

1 Like

Thank you guys!

I think you need to change as well the first Input in the dyf to:

rebarElement:Revit.Elements.Element