These days I tried running the upper code on Revit 2024 with default Python engine (CPython3), and an error is raised on the last line:
interface takes exactly one argument
Does anyone know how to instantiate the upper FamilyLoaderOptionsHandler class on Revit 2024/2025 with CPython3 engine?
Is this some kind of bug with PythonNET 2.5 class inheritance?
I would be grateful for any kind of help. Thank you in advance for any kind of help.
This is a known issue with subclassing in older versions of PythonNet
You could either use IronPython2 or IronPython3
If you are on Revit 2025.4 you can use PythonNet3 Engine
Finally you can use a random namespace for the class
Hi @Mike.Buttery ,
Thank you very much for the help and explanation.
I am sadly stuck with default version of PythonNET, until it is replaced with a new one. My IT needs to approve anything, which is not shipped by default to Dynamo. It’s a huge headache.
I tried your code on Revit 2024.3, with default CPython3 engine (I assume this is pythonNET 2.5?):
Hi @Mike.Buttery ,
My mistake. rdb is DB. I apologize for this. I corrected it in the all of the code above.
I am just trying to Load a family. The rest of the code works. The issue starts with familyLoaderOpts = FamilyLoaderOptionsHandler() line.
CPython3 (PythonNet2.5) do not ability to override .NET methods interface that have out or ref in Python (example by returning the modified parameter values in a tuple like PythonNet3).
For Revit 2024 and lower use IronPython in this case, furthermore in Dymano2.19 (Revit 2024) CPython3 has some additional bugs, probably due to targeting the NetStandard 2.0 Framework with PythonNet2.5 in a Framework 4.8 environment.
not quite, i’d keep __namespace__ = str(uuid.uuid4) executed when the class is defined. btw are u trying to generate a unique namespace every run? isn’t it str(uuid.uuid4()) instead?
Hi @c.poupin ,
Thank you very much for the explanation.
So definitely it is not possible to instantiate upper FamilyLoaderOptionsHandler class with Revit 2024.3, and default python CPython3 engine (pythonNET 2.5)?
@BimAmbit
Thank you as well for the example code. On my Revit 2024.3, it still raises an error on the last line of your code: No constructor matches given arguments: ().
Would you be able to attach the .dyn file, so that I make sure that I am not doing something wrong? Thank you for this .dyn file in advance.
Thank you @Mike.Buttery
It still raises an error on that line. There is no difference between: familyLoaderOpts = FamilyLoaderOptionsHandler()
and: familyDocument.LoadFamily(doc, FamilyLoaderOptionsHandler())
nothing fancy, throw them in a python node. but tbh i don’t see OnFamilyFound being called when i call doc.LoadFamily. best to spend some time on poupin’s article.
Alternatively you can look into building a zero touch node to do this work (no more or less secure than you writing your own Python and executing that), or leverage another means of transferring the content into the file or avoid the need (would have to have context on why you’re doing this to help with those options though).
Thank you for the suggestions @jacob.small .
Making a ‘Zero touch node’, would require writing it in C#?
i am not sure I can do this. If anyone could write such custom node for FamilyLoaderOptions, it would be of huge help.