# Error creating multiple floors in Python

**URL:** <https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879>\
**Category:** Revit\
**Tags:** python, dynamo\
**Created:** [December 29, 2024, 1:13pm UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879 "2024-12-29T13:13:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jliebana](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jliebana](https://forum.dynamobim.com/u/jliebana)\
**Post date:** [December 29, 2024, 1:13pm UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879/1 "2024-12-29T13:13:57Z")

</div>

Hello, I’m new to Python. I’m trying to create floors from a list of polygon lines, but I get this error on the curveArray adding to list:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/a/aaa3b5d3d289bae8f1cd7d08783f4eac8278d528.png)

Could I get some help? I’m using this code by now:

```auto
# The inputs to this node will be stored as a list in the IN variables.
ArrayCurves = IN[0]
floorType = UnwrapElement(IN[1])
level = UnwrapElement(IN[2])
structural = IN[3]

curveList = []
out = []

for curve in ArrayCurves:
    curveArray = CurveArray()
    for c in curve:
        curveArray.Append(c.ToRevitType())
    curveList.Add(curveArray)
    
# Place your code below this line
for c in curveList:
        TransactionManager.Instance.EnsureInTransaction(doc)
        floor = Floor.Create(doc, c, floorType.Id, level.Id)
        TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
OUT = floor

```

Thank you!

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [December 29, 2024, 3:42pm UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879/2 "2024-12-29T15:42:22Z")

</div>

hi

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/f/1fac7e199313b327508b04dfcf4c7cfa1c0b4f73.png)

```auto
import sys
import clr

import System
from System.Collections.Generic import List

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import Curve,CurveLoop,Floor,Transaction,Level,Line,XYZ

doc = DocumentManager.Instance.CurrentDBDocument

ArrayCurves=IN[0]
floortype=UnwrapElement(IN[1])
level=UnwrapElement(IN[2])
structural=IN[3]

revc=Autodesk.Revit.DB.Curve
outerCurv=List[revc]([c.ToRevitType() for c in ArrayCurves[1]])
innerCurv=List[revc]([c.ToRevitType() for c in ArrayCurves[0]])
outL=CurveLoop.Create(outerCurv)
innL=CurveLoop.Create(innerCurv)
listCL=List[CurveLoop]([outL,innL])
lslope=Line.CreateBound(XYZ(0,0,0),XYZ(1,0,0))
t=Transaction(doc,"Create a Floor")
t.Start()
floor=Floor.Create(doc,listCL,floortype.Id,level.Id,structural,lslope,0)
t.Commit()
OUT = type(outerCurv),type(outL),type(listCL),floor

```

cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![jliebana](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jliebana](https://forum.dynamobim.com/u/jliebana)\
**Post date:** [December 29, 2024, 6:32pm UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879/3 "2024-12-29T18:32:16Z")

</div>

Thank you for your quick answer!  
Unless I’m wrong, doing those changes I get only 1 floor as a result. Unfortunately I need to proccess the list from python to create as many floors as polygons are in input[0]

Am I missing anything?

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [December 29, 2024, 7:57pm UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879/4 "2024-12-29T19:57:08Z")

</div>

I thought you were trying to create the ground between these 2 curveloops as there is common matter between the 2 grounds it will generate warnings  
what you are trying to do is achievable with the ootb node  
if you make a for on the list this should create 2 floors  
I’m writing this from phone so be careful  
` t.Start() floors=[] for c in listCL: f=Floor.Create(doc,c,floortype.Id,level.Id,structural,lslope,0) floors.append(f) t.Commit() OUT = floors`

edit:

```auto
t.Start()
floors=[]
for c in listCL:
    f=Floor.Create(doc,List[CurveLoop]([c]),floortype.Id,level.Id,structural,lslope,0)
    floors.append(f)
t.Commit()
OUT = floors

```

You will get a warning like previously explained

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/b/6b3d7dd155c057acbe9fd82ef92dc1f5d9b746e4.png)  
if you validate you will have your 2 floors  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f61b8aa87b1cb6d9517d0157e2a1ae4918c9b125.png)

Cordially  
Christian.stan

---

<div class="post-metadata">

**Author:** ![jliebana](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jliebana](https://forum.dynamobim.com/u/jliebana)\
**Post date:** [December 31, 2024, 8:20am UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879/5 "2024-12-31T08:20:07Z")

</div>

Good morning, and thank you very much. You made my day with your help! Now it’s working as I was expecting to, and can continue.

Have a good day, and a happy new year!  
Regards

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [December 31, 2024, 8:28am UTC](https://forum.dynamobim.com/t/error-creating-multiple-floors-in-python/106879/6 "2024-12-31T08:28:28Z")

</div>

Hi @jliebana , please mark Christians solution if it work for you so it probably could help other in the future…and happy newyear to you as well 😉 😉
