Difficulties With OkPy in Revit 2025

Hello! I’m navigating translating all our IronPython scripts to CPython with the Orkestra integration with Revit 2025 - it’s been a process so far and I’m nearly done but I’m having a really difficult time with this portion of the script which used to work totally fine in 2024 and prior (from Mostafa’s video series on exploded axonometrics):

for placedRoom in allPlacedRooms:
#Getting the geometry of the room
geom = placedRoom.get_Geometry(Options())
roomSolid = list(geom)[0]
#Creating DirectShape Geometry
directshape = DirectShape.CreateElement(doc,ElementId(BuiltInCategory.OST_GenericModel))
directshape.SetShape([roomSolid])

Each time I run this script, I get the error “TypeError : No method matches given arguments for SetShape: (<class ‘Autodesk.Revit.DB.Solid’>).” Anyone have any ideas as to why this is occurring? As far as I’m aware, a Solid is a totally valid input of DirectShape.SetShape.

I’m on 1.9.3 for now - let me know if an upgrade will help!
-James

As an FYI, I spoke to a more professional coder than me and he suggested I use the List method as imported from System.Collections.Generic (the previous method of import System or From System import List was not working with the new CPython interpreter). The new code looks like:

for room in allPlacedRooms:
try:
geom = room.get_Geometry(Options())
ds = DirectShape.CreateElement(doc, ElementId(BuiltInCategory.OST_GenericModel))
roomSolid = ListGeometryObject
room_solid = next((g for g in geom if isinstance(g, Solid) and g.Volume > 0), None)
if not room_solid:
continue
ds.SetShape(roomSolid)

and that works!

1 Like

Apologies for the late answer and thanks so much for sharing the solution here!
Indeed the CPython interpreter in 2025 uses pythonnet 2.5 which has it’s quirks. We’ll be moving to pythonnet 3 in next versions which will improve this.