Hi everyone !
Can’t understand why but my code returns two floors where I expect it to only create one.
For a bit more context, rooms
and Curves
lists do have the same length. listCurveLoop
is a unique closed loop for each index i
I tried to place only an f = Floor.Create(doc, listCurveLoop, UnwrapElement(floorType).Id, rooms[i].Level.Id)
inside the Transaction handler
I get only one floor in my log output but two in my Revit model
Here is the code :
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry 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)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
log = []
ERROR = []
Curves = UnwrapElement(IN[0])
floorType = IN[1]
rooms = UnwrapElement(IN[2])
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(len(Curves)) :
listCurveLoop = []
for c in Curves[i] :
newLoop = CurveLoop()
for m in c :
try :
ri = m.ToRevitType()
newLoop.Append(ri)
except :
pass
listCurveLoop.append(newLoop)
if listCurveLoop :
try :
log.append([rooms[i],[Floor.Create(doc, listCurveLoop, UnwrapElement(floorType).Id, rooms[i].Level.Id)]])
except :
ERREUR.append([rooms[i],sys.exc_info()[1]])
else :
ERREUR.append([rooms[i],"Invalid Curve"])
TransactionManager.Instance.TransactionTaskDone()
OUT = log, ERROR
I suspect I did something wrong with for loops but I can’t put my finger onto what and tried asking GTP for help which wasn’t successful
Thank you for the time taken to tackle this issue with me