Shortest Route?



Hi all,

I read a post that tried to cover what I’m asking but it didn’t really help, and i’m not sure how to get the nodes to work correctly that exist, if they do work…!

Basically me and a colleague have been working on a script to size cable trays automatically, and it works a treat, however there is still a process of going into the model and manually specifying each run and the associated cables on each.

What I’m looking to do as per the image below, is get a route (indicated in blue) and be able to choose the cable trays marked by X’s (maybe even the fittings) Then when I have the selected elements fill a parameter in with something like “SM08” as a cable reference thus allowing me to create cable references and size them all automatically…

Does anyone know a method I could use to complete this task?


Any ideas anyone?:thinking:


This is all I can find at the moment:

Just try something and someone will surely help to improve it :slightly_smiling_face:


Thanks, but however I’ve already tried all the nodes on that package. I can get close to what I need but it just isn’t consistent and I can’t get the exact values I need. Because cable trays don’t have a flow or “upstream” it’s difficult to identify which cable tray should be next other than trying to follow a direct route which gives the shortest distance.


Please send a screenshot of your attempts with some explanation, we will see if someone can help :slightly_smiling_face:


Test.dyn (26.3 KB)

What i’ve done so far (which needs cleaned up) is select the distribution boards, find the closest cable tray and isolate them.
I’ve also isolated the switch board and it’s closest cable tray also.

So what i’m trying to basically do, is find the closest route from the Distribution Boards cable tray to the Switch Boards cable tray, thus selecting all elements on the route and applying the cable reference per the DB.

MEPover allows me to get all the connected elements in the whole system (See the “Elements in connected network” node. And it also allows me to get the connector info (See the MEP Connector info" node) Now, I feel this is getting relatively close? I just need to find a way to filter out the cable trays that are of no relevance to me.

I could attach the Revit file if needed, but It’s just a little cluster of cable trays to test, nothing that can’t be quickly redrawn if needed to test.


I did not try anything like that yet but I wonder if this discussion could not be of interest here:
See also:


Close. It still requires me to automatically input the route (which is just as quick doing in Revit)

I forgot in Revit there is a way to actually get the most appropriate route by selecting one cable tray I.E the one I found nearest the distribution board, and then hover of the one you want the shortest route too (switchboard nearest cable tray) hit tab and itll give you the most direct route.

I can’t imagine Dynamo will allow you to do something similar?

If not, I guess I’ll give up on trying to find an automated route for this,
At the moment we are simply selecting the route we want and manually doing it within Revit, while it isn’t a long process, some larger projects it will be.


So this is where I got, I went through 3 different scripts with each different methods and feel like this is the closest? Converted the cable trays into lines and split them into lots of points, I’ve then created a line of best fit which could be used as a directional item? Could I force this line of best fit to then stick to only the points instead of being in empty space? That way it should in theory follow the containment around point by point until it reaches the final point?

Please ignore how ugly the script is, it’s a work in progress :neutral_face:



I’ll bump this one last time in the hopes someone else may have a look and see something i’m missing.



See what’s here maybe:


Appreciate all your help. That link gave me the right stuff to create what I needed. Thanks a lot.


@Vykr Any chance you are willing to share your final graph? I am attempting to do something very similar.


Sure, find below:

DynaTools.ShortestPath.dyf (14.2 KB)
01_ShortestPath.dyn (47.3 KB)