I’m getting this error in the RPS console when attempting to create walls
Exception : Microsoft.Scripting.ArgumentTypeException: expected BuiltInParameter, got ElementId
here my code:
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()
It’d would be helpful to note on which line you are getting error. But judging from this code it’s on FilteredElementCollector. As I’m writing from mobile I’ve no way to check to be sure but I’d remove method OfCategory(BuiltInCategory.INVALID) as it’s kind of contradicting with OfClass(WallType). Wall types are also part of BuiltInCategory.OST_Walls. Or change collector methods entirely to
OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements().
As for BuiltInCategory.INVALID I wouldn’t be surprised if it were returning id: -1 so it would create this exception.
I see, I think I know what is going on. If you use [quote=“REDO_79, post:1, topic:3422”] level_Id = l.Id
[/quote] you get element of ElementId class so you don’t need to retrieve it again. Try placing wall like this: Wall = Wall.Create(doc, crv, (wall_Id), (level_Id), 3.00, 0.00, False,True)
hi @REDO_79 you have any update if you solved this? have you tried removing BuiltinCategory and just leave the OfClass in level_Types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.INVALID).OfClass(Level).ToElements()?