Hi Friends,
i am trying to set layout as Maximum spacing for some rebars but i am getting an error in Revit 2020.2
this is my code:
import sys
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import*
from System.Collections.Generic import IList, List
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
# dynamo curves as input
rebar = IN[0]
spacing = IN[1]
array_length = IN[2]
rebars = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i, j, k in zip(rebar, spacing, array_length):
rebar = i.GetShapeDrivenAccessor().SetLayoutAsMaximumSpacing(j, k, true, true, true)
rebars.append(rebar)
TransactionManager.Instance.TransactionTaskDone()
OUT = rebars
this is the error
May anyone tell me how to fix the code to get the right output.
Thanks in advance.
Hi @hanywillim You are on write path but there are few things that u missed and that’s causing this error for u, here i’m pasting the code
rebar = UnwrapElement(IN[0])
spacing = IN[1]
array_length = IN[2]
rebars = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i, j, k in zip(rebar, spacing, array_length):
rebar = i.GetShapeDrivenAccessor().SetLayoutAsMaximumSpacing(j, k, True, True, True)
rebars.append(i)
TransactionManager.Instance.TransactionTaskDone()
OUT = rebars
Here As u could see in comparison with yours to follow your approach i kept it same but at the same time few alterations:-
The UnwrapElment wasn’t used. (For more check this 4.4 Unwrapping Revit Elements - Dynamo Python Primer (gitbook.io) )
true will be written with " T " in Caps.
I hope it helps.
Regards,
BM
Hello friends, thank you for your contributions, I am using revit 2025 but it does not generate the steels, I get this error, I hope you can help me, thank you
Hi @JOSECERVE
Could u please show the inputs as it seems you might hv given the float instead of a list out of spacing or array_length and as you are using forloop so it has to be a list that’s what the warning states.
Regards,
BM
Hello friend, I share the image of the entries, I tested it in meters and millimeters and it reports an error, the structural design number does not work for me, deactivating the first bar and last bars that is why I am testing this python, thank you
As per the snip it’s exactly what i said earlier, the IN[1] is coming as a Float/Double where as it is supposed to be a list if u want to iterate over it
How could I solve it friend, do you have to edit the code?
Please see as you created a new thread and @Mike.Buttery replied with the answer for it
Please use the <\> code format when posting code
The zip(rebar, spacing, array_length) function is expecting three iterables such as a list. Ideally these are the same length, otherwise the data will be truncated
It appears one of the inputs, which are unknown as you have not provided the information, is not a list (or iterable) so the zip function cannot process the given variables
When you get a spare moment take the time to read How to get help on the Dynamo forums
here it is.