Hi everybody,
I’m using the Revit API method to create rebar free form curve as indicated here, but I’m stuck how to iterate at the same time in the Normal verctor list (Normal_vect) and its corresponding curve list (crvs) to be able to create the rebar doc…I thought to use zip function but I dont know how can I write the correct syntax to iterate in each sublists nested in my two lists (I want to keep the structure of my list)
here my graph:
Note: ignore the error until I haven’t correctly write the correct syntax of the function zip to iterate between curves list and vector list
Here my code:
Rebar
import sys
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
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
geo = IN[0]
bar_type = UnwrapElement(IN[1])
host = UnwrapElement(IN[2])
vect = IN[3]
# converting dynamo curves to Revit curves
crvs = []
temp = []
for l in range(0, len(geo)):
for c in geo[l]:
temp.append(c.ToRevitType())
crvs.append(temp)
temp = []
# get nornal vectors of each curve
Normal_vect = []
for l in range(0, len(vect)):
for v in vect[l]:
temp.append(v.ToRevitType())
Normal_vect.append(temp)
temp = []
rebars = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(0, len(crvs)):
for j in crvs[i]:
rebars = [Rebar.CreateFromCurves(doc, RebarStyle.Standard, bar_type, None, None, host, j, i, RebarHookOrientation.Left, RebarHookOrientation.Right, True, False) for i, j in zip(crvs, Normal_vect)]
TransactionManager.Instance.TransactionTaskDone()
OUT = rebars
Thanks.
