Family-Parameter(Window) based on nearness/enclosure to Room

Here comes a Revit knowledge dump, followed by what I hope will be a solution.

Family Instances have three properties which allow reporting of rooms: .Room[phase], .ToRoom[Phase], and FromRoom[phase]. The [phase] portion is required as there can be different rooms in the same spot in different phases because buildings are dumb. Here is the link to the ‘FromRoom[phase]’ property in the Revit API docs (I’ll let curious individuals find the others on their own).

So we now have a way to get the room properties, and we likely (hopefully - otherwise jumping into the API this fast may not be advisable) know that these points are set in the family environment by enabling the room calculation point, with Windows and Doors having the ‘Two Ended’ spline which defines the from room (start) and to room(end) values, while other family types have just a single point. At this point you may be asking yourself “if doors only have a ‘ToRoom’ and ‘FromRoom’ point, what should be returned by the ‘Room’ property?” This is a valid question, and one which the development team said ‘well likely we don’t want to return null’ and make people ask twice, so let’s return one of the other values too’, and now the ToRoom property value is the same as the Room property value. It’s not necessarily awesome, but anything the put there would be wrong 50% of the time, or we’d have more nulls to deal with.

So what you’re seeing with the ‘FamilyInstance.Room’ node is that the rooms are returning correctly when they align with the ToRoom point, but not reporting anything when that point falls in an invalid room.

Knowing this… we now must question how to get what we want? Fortunately the Python code is relatively simple overall, and can be easily written to work with a few different conditions while keeping speed high:
image

Effectively “ask for the room, and if you get none, ask for the from room, and if you still get none surface a string”.

DYN:
3216581848079686336return_room_toroom_or_fromroom.dyn (12.3 KB)

Hope this helps!

2 Likes