AttributeError for FileType object

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. :stuck_out_tongue_winking_eye:

A long time known issue.
Different wrappers and python engines can bite you.
Simple fix:
https://discourse.pyrevitlabs.io/t/how-do-i-get-viewfamilytype-name/508

https://forum.dynamobim.com/t/python-walltype-cant-get-the-walltype-name/46870

Thank you @aaronrumple for pointing me in the right direction. My search terms were just off enough to not bring up these results, but I see the issue in a number of forums now.

It’s curious that RPS handles this with no error. I’ve been doing script “sketches” in RPS for the past few years now, and I guess so few of these have made it to my pyRevit ribbon that I’ve never encountered this issue before.