Python Shortest Walk 3D: Interpolate grid of points with start & end point to get shortest curve thorough points of grid

If you don’t know what you’re doing start with Dijkstra, with a single actor, the most basic one.

Hell, I haven’t yet implemented A-star myself. Mostly because I don’t have time for that. And because I’m stubborn and I wanna do it myself :smiley:

You could also implement a graph library, I like to use networkx in GHPython, uploaded a simple example of computing shortest paths on a RhinoCommon mesh here:


I personally learned by doing project Euler challenges and reading other people’s solutions. Also see here for a bunch of Python algorithms.


Thanks a lot. I will study that!
Please check you mails!


1 Like

Thanks a lot for that hint!

Chris Hanleychanley also posted some useful tips/resources here: Handy Tips for GHPython Editor/Component (Rhino 6)

maybe you need first to draw a box between the two points : start & end, that make it easier to find the shortest line

why do you thank that the box helps? The points that are stored inside have an similiar array like mine in the script I posted.

Interesting information! Thanks a lot!

you want the short way between A and B so you need to reduce the possibilities and the number of points ,you can’t use all points

This is no generic rule. Image a bigger box between the start and end point as obstacle and you won‘t find the Route.

About learning resources: I really enjoyed „the coding train“ YouTube channel by Daniel Shiffman and his book „the nature of code“. It‘s mostly written in processing, but it‘s easy to translate. He also has some path finding tutorials. The guy is super funny in my opinion :slight_smile:


Do you understand the idea? 2 points in 3d space the shortest route is inside the box between them

I know what you mean. As I said, not if you have obstacles…

Guys, I am not able to implement the pseudocode example “A Star” into my script. Maybe someone can help me with the script. You can find the important part at the bottom of the script. Thanks a lot. Here is my new file: (47.0 KB)

:rofl: Welcome to my world :smiley: I tried to do the same thing. Better find an example in python.
Google for it.

Google was my friend the last hours. I think the problem is more in understanding the code as a “lets say beginner”. Please take an eye on my script.

I find pseudocode syntax surprisingly more difficult than the python syntax :wink:

I think because every person creates their own view of “pseudo” syntax

When I understand the terminology right, i already implemented a python syntax. What do you mean with pseudocode syntax? You mean the abstract comments and variable names that are mentioned inside univeral written pseudocodes?


This is what I have so far:

I do not know how to insert my list of points (border_pts), end_point and start_point0 into the script underneath that contains just 2D-tuples. border_pts is a 3D grid.

Maybe someone can help me to solve that.