This post is about creating Path of Travel (a new feature introduced in 2020) and its travelled paths Schedule by using Revit Dynamo Application. To cover in a depth, post is presented into two sections:
- Creating Path of Travel and its Schedule with Dynamo OOTB nodes
- Creating Path of Travel with IronPython
The demo is to create evacuation plan for this floor plan as shown in figure 1.0. And we would like to know what is the shortest route, what is the distance and how long it will take to the Staircase(emergency exit) from each of the room. (You can download this demo Revit-2020 file from here.)
So, let’s start our first part by launching dynamo in Revit 2020. The first step is to filter out the rooms by its Name which are the Staircase Room and the rest of the rooms as shown in figure 1.1.
After getting the two filtered list, we are going to create PathofTravel by providing a Floorplan, rooms’ start(s) and end point(s) from Room.Location node, and a boolean value as the arguments for PathOfTravel.ByFloorPlanPoints node from dynamo node library. (figure 1.2)
Now, we have got our paths of travel from the staircase to each of the rooms (figure 1.3). Additionally, you can add more obstacles from the Revit User Interface > Analysis tab > Route Analysis Setting and run the script again. (figure 1.4)
The next step is to create a PathOfTravel schedule with ScheduleView.CreateSchedule node from dynamo library. Provide the first argument, PathOfTravel Category from collecting its element, Name and Schedule Type as second and third arugments respectively. To add the schedule fields, we can query schedulable fields from the created schedule with ScheduleView.SchedulableFields node. Collect the items from the schedulable fields list by indexing and add to the created schedule by using ScheduleView.AddFields node. (figure 1.5)
After the script execution, we will be seeing the Travelled Path Schedule as shown in figure 1.6.
This is the end of our first part and you can download the complete script from here.
We can start our part two by deleting Path Of Travel (blue group) and Path Of Travel Schedule (yellow group) from the script as the demo below.
Import RevitAPI, RevitServices and from RevitDB Analysis namespace import PathOfTravel class. And import the DocumentManager and TransactionManager from RevitServices as usual. We are going to need one more class which includes dynamo type conversion methods, GeometryConversion.
#dynamo version 2.3.0 import clr clr.AddReference("RevitAPI") clr.AddReference("RevitServices") # import path of travel from Autodesk.Revit.DB.Analysis import PathOfTravel from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager clr.AddReference("RevitNodes") import Revit # Import geometry conversion extension methods clr.ImportExtensions(Revit.GeometryConversion)
PathOfTravel Class is only available in Revit API 2020 version. It has quite a number of ways to create the paths. For this demo,we are going to use CreateMapped method, the third one from the method list below, which is the most appropriate to use and similar to PathOfTravel.ByFloorPlanPoints dynamo node from part one.
CreateMapped has three arguments/parameters ; a view, a list of point(s)(startpoint) and a list of point(s) (endpoint). But you may notice the type of points require are XYZ which is a Revit type point. So, we have to convert Dynamo type room location points into XYZ Revit type by using ToXyz() method from Revit.GeometryConversion namespace. (Dynamo to Revit/ Revit to Dynamo type conversion methods include in this namespace).
# view input view = UnwrapElement(IN) # if not a list make a list startpts = IN if isinstance(IN,list) else [IN] # make dyn point to revit xyz point startpts = [p.ToXyz() for p in startpts] # make xyz endpts = [IN.ToXyz()] # current document doc = DocumentManager.Instance.CurrentDBDocument # transaction start TransactionManager.Instance.EnsureInTransaction(doc) # create path of travel paths = PathOfTravel.CreateMapped(view,startpts, endpts) # transaction end TransactionManager.Instance.TransactionTaskDone() # output paths OUT = paths
Well, this is the end of part two, complete source code you can download here. Cheers!
Revit API screenshot used from https://www.revitapidocs.com .