Update ToRoom and FromRoom

Hello,

I see this has come up a couple times on the forum in past years, but I haven’t seen a definitive solution yet. How can I update a door’s To Room and From Room parameters? These parameters are set when the door is placed based on the direction of the door swing, but the parameters do not update when the door swings are updated.

Has anyone figured out how to make these parameters update according to the current door swings?

Thanks!

Can’t say I have seen this a can you post a simple model with two rooms and two instances of a door where the door goes from room A to room B a and one is flipped so the to-room should be reversed?

Door ToRoom Test.rvt (6.0 MB)

Sure, here it is.


image

If you turn off specific reporting points in the door you can manually swap the to/from room. You cannot override it to anything but the two possible rooms, however.

Most firms these days I see are using two parameters and a tick box to report in vs out these days, then developing scripts/addins to jam this into the door.

1 Like

Thanks Gavin. I also figured out an alternative solution.

  1. Get door elements
  2. Get location points of door elements and current ‘To Room’
  3. Generate a vector with the door location as a start point and the ‘To Room’ location as an end point
  4. Check if each door is facing the current ‘To Room’ by getting the dot product of the Step 3 vector and the door FacingOrientation vector. (Positive dot product means the door opens into the current ‘To Room’, negative dot product means the opposite.)
  5. If the dot product is negative, flip the ‘To Room’ and ‘From Room’ values (using the Python script below for this.

Script:

# Load the Python Standard and DesignScript Libraries
import clr
import sys

# Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

# Get the active document from the DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
doorList = UnwrapElement(IN[0])
isFlippedList = IN[1]

# Place your code below this line
TransactionManager.Instance.EnsureInTransaction(doc)

for i, isFlipped in enumerate(isFlippedList):
    if isFlipped == False:
        doorList[i].FlipFromToRoom()

TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
OUT = doorList

Do you see a downside to this? This approach doesn’t allow users to manually adjust the To and From values, but it will ensure the values are set correctly based on door swing direction.

Seems a bit likely to have issues with the door’s flip state as I don’t think facing orientation catches all of those well… though I could be confused.

One foolproof method is to use Element.Curves to pull the curve elements from the door instances, remove anything not an arc, or anything without the standard line style to account for a dashed line on double acting doors, and find the center point of that. Pull the room at that point and you’re good.

Benefit here is that the point you’re pulling will be in the room in question 100% of the time. Drawback is that it won’t be as quick performance wise and that your line styles need to be consistent to account for double acting doors.

1 Like

I’ve been testing and haven’t had any issues with the door flip state causing the facing orientation to read incorrectly. However, all of the door families in use need to have the door swing consistently placed on the exterior side in the .rfa for this to work. I was testing with default Autodesk families and encountered a double door where the swing graphics were on the opposite side in the .rfa file, which caused an issue.

I had to tweak the graph and add some additional logic in the Python script to get exterior doors to work. The updated graph and script are below. I’ll provide updates if I run into issues, but so far this is working well.

Screenshare - 2024-03-23 6_40_52 PM.mp4 [video-to-gif output image]

# Load the Python Standard and DesignScript Libraries
import clr
import sys

# Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

# Get the active document from the DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
doorList = UnwrapElement(IN[0])
isFlippedList = IN[1]
toRoomList = IN[2]
fromRoomList = IN[3]

# Place your code below this line
TransactionManager.Instance.EnsureInTransaction(doc)

for i, isFlipped in enumerate(isFlippedList):
    
    #First condition: current ToRoom value is null and door is facing room
    #Second condition: current FromRoom value is null and door is facing away from room
    #Third condition: Door currently faces FromRoom, and ToRoom and FromRoom both have values
    if \
    (toRoomList[i] == None and isFlipped == False) or \
    (fromRoomList[i] == None and isFlipped) or \
    (isFlipped and (toRoomList[i] != None and fromRoomList[i] != None)):
        doorList[i].FlipFromToRoom()


TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.

OUT = doorList
1 Like

The Revit solution is to add/activate the Room Calculation Point in the door family, then it magically will update on it’s own. Unfortunately you can’t control the location of that point with a parameter or similar so most will probably choose not to use that thingy and instead rely on coding… :upside_down_face:

1 Like

Hi @ThorbjornH Sparrow have some nodes for control calculation point position in a project

1 Like

Interesting, @sovitek - thanks, good to know! Would be nice if it could be locked to a Reference plane or something instead.

1 Like

yes indeed