Hi everyone, I’m new with Python and I’ve been trying to create Revit Floors. When I create a Floor from a Polygon the code works. However, when I have a list polygons and I want to create multiple floors at the same times my code doesn’t work.
It seems that the error is when I try to create the CurveArray(), so I’m doing something wrong in the for loops. Also I’m not sure how to create the multiple floor in a for loop. I leave the code that I’ve done. Hopefully someone could help me with this. Thanks!
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc=DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
Curvas = IN[0]
Nivel = UnwrapElement(IN[1])
Tipo = UnwrapElement(IN[2])
Boolean = IN[3]
Perimetro=CurveArray()
revitfl = []
for i in Curvas:
revitfl.append(i.ToRevitType())
for j in revitfl:
Perimetro.Append(j)
#TransactionManager.Instance.EnsureInTransaction(doc)
#for k in Perimetro:
#Suelo = doc.Create.NewFloor(Perimetro(k),Tipo,Nivel,Boolean)
#TransactionManager.Instance.TransactionTaskDone()
OUT = (revitfl,Perimetro)