Shortest Route?

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:

1 Like

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:

1 Like

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)


Hi Vykr!

I have some question about your graph, as Im trying to do some of the same things. First of all, nice job! :slight_smile:

In my project, I have eletrical sockets placed all over. I then want to find the length from that socket and to the eletrical panel. This is of course not so hard, but I want the route/distance to be calculate by using the nearest cable tray (as of course, the length of the cable has to my placed on the cable tray…)

Any suggestions on how to solve this? I cant quite get your graph to fit my purpose (or understand all of it)


I was able to take Vykr’s graph and change it to work by the shortest route through cable tray and conduit (or a combination of the two) and spit out the overall length as well as the path the cable took (each segment tray/conduit). I have had to make it pretty custom to work with our company naming standards and parameter names but I can take some pictures to show you what I did if you would like.

1 Like

I would love to see how you solved this. I found a node that calculate the shortest path, and then I took the curve lenght of the cable trays and added them up to get the overall length.

However, the problem is when the cable trays are not connected 100% to each other (but hare very very close to).

Hi Erik, I sent you a private message to try clear it up.

However as I mentioned in the message, it is very tempermental and very difficult to get it to work correctly. Yes, one of the biggest issues is that things need to be connected or as close to connected as possible. It was the only way I could get it to identify which elements I was using. Perhaps there could be a clever automated way to pick up the nearest specific element and use that?

I’d really like to see any improvements on how this script could be done as mine was very much a work in progress.

Because these images are so large I suggest doing this: Right click image…open image in new tab.

Alright…I will try my best to explain the madness that is going on here. The image exported from Dynamo was too big to upload so I split it into two. I will probably have to add more later as I do not have much time now but wanted to put this out there for digestion. Also, I do not remember everyone who helped me with this but big thanks go out to @Vykr for sharing his original graph and @awilliams for answering a bunch of my questions.

First you have to understand the naming convention we are using. Cable Tray is labeled as such 20CT01LV01 (first double digits denote the area of the project, second double digits denote that it is a cable tray, third double digits denote the network, forth double digits denote the power level, and the final double digits denote the segment of that cable tray network). A network, in this case, is a single continuously connected cable tray (if you were to tab onto it multiple times it would select the entire thing). This is important because ShortestPath (as mentioned before) MUST be completely connected in order to function properly. The Cable Tray label is constructed using three parameters: Cable Tray Network (20CT01), Cable Tray Power Level 1 (LV), and Cable Tray Segment (01).

Conduit is much simpler and is named 20LV001 (first double digits denote the area of the project, second double digits denote the power level, and final three digits denote the network or single run of conduit). This data is entered into the same Cable Tray Network parameter (I know it is not a cable tray but just go with it for now).

In terms of modeling practices, cable trays have to be connected completely and conduits have to be the same. If you want a cable to run off of a cable tray through a conduit the conduit must be connected to the cable tray.

The graph starts off with a few data shapes windows which help narrow down the area in which we are doing routing. The second data shapes window allows the user to select which Cable Tray Networks the user wishes to use, the power supply, the cable destination, the power level, and any specific conduits that need to be used (if any). The final data shapes window allows the user to select specific cable tray segments to ignore in an MCC room (the cable trays tend to do loops and I found that sometimes ShortestPath would not pick the shortest path so this was a work around.

Just above the data shapes node groups I have two groups that make sure all cable parameters are cleared and that a date is set for the time this was run on a specific cable. After that the graph figures out which elements to use based on your selections and pumps them into the ShortestPath node. It then pumps out data to a number of other groups. The top group on the right creates a cable routing label which lists all segments of the route concatenated with commas. The group below that creates separate labels for individual route parameters (this was done so that when we export it into excel the engineers could use the data in different ways). The third group calculates the total travel distance and puts it into a parameter. The bottom four groups get the closest points from the selected networks to the power supply and cable destination and calculate the Field Routing distance of the cable and plug those values into parameters.

When all is said and done, this is what the data output looks like:

The end result, for us, was that we spent a bit more time making sure that cable tray and conduit were modeled correctly but saved a TON of time on the engineering side calculating quantities. Our contract required us to provide this data so using this tool was well worth it. If you are not required to provide cable lengths and routes, this would be complete overkill.


Hey, just as an FYI, if you zoom so you can read a node name and hit the camera symbol in the top right it will save your entire graph as a png.

Then we can save it from the website and scroll along…

Excellent work :slight_smile:



That is exactly what I did but the image was too large to upload to the forum so I chopped it in half to reduce the file size. ><

1 Like