Create walls from lines

Hi All,

I’m traying to create walls from lines using profil method as described below:

but I’m getting thie following error in the RPS console:

Exception : Autodesk.Revit.Exceptions.InvalidOperationException: Could not construct a proper face with the input curves to create a wall correctly.
à Autodesk.Revit.DB.Wall.Create(Document document, IList`1 profile, ElementId wallTypeId, ElementId levelId, Boolean structural)

Pls check my code below:

from Autodesk.Revit.DB import *
from System.Collections.Generic import IList, List
uidoc = __revit__.ActiveUIDocument

doc = uidoc.Document


t = Transaction(doc, 'create Model lines')

wall_Types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.INVALID).OfClass(WallType).ToElementIds()
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.INVALID).OfClass(Level).ToElementIds()

for w in wall_Types:
    w_type = doc.GetElement(w)
    if w_type.Name == "Ext. Voile BA 20":
        wall_Id = w
    
for l in levels:
    lvl = doc.GetElement(l)
    if lvl.Name == "Niveau 0":
        lvl_Id = l

# Create Points and Lines:

c = 1/0.3048
Pt0 = XYZ(-0.60*c,-0.60*c,0)
Pt1 = XYZ(0.60*c,-0.60*c,0)
Pt2 = XYZ(0.60*c,0.60*c,0)
Pt3 = XYZ(-0.60*c,0.60*c,0)

Lines = []
Line1 = Line.CreateBound(Pt0, Pt1)
Lines.append(Line1)
Line2 = Line.CreateBound(Pt1, Pt2)
Lines.append(Line2)
Line3 = Line.CreateBound(Pt2, Pt3)
Lines.append(Line3)
Line4 = Line.CreateBound(Pt3, Pt0)
Lines.append(Line4)

Curves = List[Curve]()

t.Start()

for i in Lines:
    Curves.Add(i)
    Walls = Wall.Create(doc, Curves, wall_Id, lvl_Id, True)

t.Commit()

Can you help me to solve this issue pls?

Thanks.

Try with wall creation out of for loop

1 Like

@MarcinTalipski

I tried creating the wall outside of the for loop as you did, but I still get the same error!

Thanks.

When you are using method

iList[DB.Curve]() is profile/shape of single wall. If you wish to create four walls, of specific type, with set of lines, you should use:

Then the code could look like this:

Walls = []
for curve in Lines:
    wall= Wall.Create(Document, Curve, ElementId, ElementId, Double, Double, Boolean, Boolean)
    Walls.append(wall)
2 Likes

@MarcinTalipski

Effectively, I discovered my mistake and corrected it. I initially chose the wrong method, which created a wall profile based on lines in the XZ or YZ plane, but I wanted to create walls based on lines in the XY plane. To solve this, I should have used the method you employed, which resolves my issue.

Thanks.

2 Likes