Can someone tell me why this script fails? I’m running the latest versions of Windows 11, Revit 2024, pyRevit, and RevitPythonShell (r.i.p.). The following bit of code runs just fine in RPS, returning a dict
of FloorType
objects with their names as keys. However, when I run it in pyRevit using a pushbutton, I get an AttributeError
indicating that the FloorType
objects have no attribute Name
(this also happens in Revit 2025). I know for a fact that they have this attribute, so I’m wondering if they got inadvertently wrapped in some other object without that attribute.
from pyrevit import HOST_APP
from pyrevit import DB
doc = HOST_APP.doc
floor_types = (DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Floors)
.WhereElementIsElementType()
.ToElements())
floor_types = {floor_type.Name:floor_type for floor_type in floor_types}
Error Output:
IronPython Traceback:
Traceback (most recent call last):
File "C:\[insert path here]\script.py", line 11, in <module>
AttributeError: Name
Script Executor Traceback:
System.MissingMemberException: Name
at CallSite.Target(Closure, CallSite, Object, CodeContext)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope)
at PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)
This one has me stumped. I’m wondering if I’m just missing something obvious. (And I even tried rebooting my machine.)
Thanks all for your time.