Unable to create wall by API

Hi everyone

I’m getting the following error in the Revit Python Shell console (that I guess it would be the same by using python in dynamo ) when attempting to create walls:

Exception : Microsoft.Scripting.ArgumentTypeException: expected BuiltInParameter, got ElementId

I guess it’s related to the level Id which I can’t define correctely

Pls check my code below:

from Autodesk.Revit.DB import *
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document

selection = uidoc.Selection.GetElementIds()
wall_Types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.INVALID).OfClass(WallType).ToElements()
level_Types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.INVALID).OfClass(Level).ToElements()

for w in wall_Types:
    if w.Name == "Ext. Voile BA 20":
        wall_Id = w.Id

for l in level_Types:
    if l.Name == "Niveau 0":
        level_Id = l.Id

t = Transaction(doc, 'Create walls')

t.Start()

for s in selection:
    crv = doc.GetElement(s).GeometryCurve
    wall = Wall.Create(doc, crv, ElementId(wall_Id), ElementId(level_Id), 3.00, 0.00, False,True)
t.Commit()

How to solve this issue?

Thanks.

They are already element Ids, don’t pass them in to the element Id class.

2 Likes

@GavinCrump

I tried it the first time as you mentioned, but bizarrely, it did not work. Then it worked the second time.

Thanks a lot.

1 Like