The dynamo script places instances of a hexagonal detail item in a grid and colours them based on their distances from destination points (detail family also provided).
The script was formulated as a quick alternative to the built-in Revit “Path of Travel” node, providing an overall visualisation which can double as intuitive diagrams in presentation decks.
It utilised the Dijkstra algorithm routing through the centre points of a hexagonal grid, with the tolerance set to allow the path-finding to skip over one adjacent hexagon for more efficient travel. The attached PDF illustrates the tolerance setting and highlights some use-cases.
One of my frustrations with using LLMs for coding, specially in the Dynamo space is that the ability to use the Revit or DesignScript API is limited to the publicly available code.
Time and time again I see LLMs create helper functions, repetitive testing or wrappers for built-in API methods because the ‘knowledge’ of the API is so thin.
I assist my agent (when I use one) by utilising the Autodesk Help MCP and an extensive Revit and Dynamo API stub library for my IDE Visual Studio Code. This allows for discovery of methods that are not documented on the web as DesignScript is closed source. For example this is an excerpt from the python stub for the DesignScript Geometry Polygon class. Note how the Center() method is built in. No need for a helper.
class Polygon:
PlaneDeviation: float
"""Returns maximum deviation from average plane of polygon."""
Points: Array[Point]
"""Returns all the segment start / end points."""
@staticmethod
def ByPoints(points: IEnumerable[Point]) -> Polygon: ...
def Center(self) -> Point:
"""Returns average point of corners of polygon"""
...
def ContainmentTest(self, point: Point) -> bool:
"""
Returns whether an input point is contained within the polygon...
Further little minor annoyances like creating a 3d point Point.ByCoordinates(px, py, z_level) when a 2d overload exists.
Finally it appears that the pathfinding is not checking for blocked areas or crossing blocked areas when calculating the distances
Cyril is correct that SciPy library, which is already available in Dynamo python (PythonNet3 and CPython3 engines), can be for more efficient as it uses compiled code and has built in algorithms for creating coordinate grids and shortest paths.
Check out the following page Red Blog Games - Hexagons it is an absolute goldmine of info on how to work with hex grids and pathfinding
Edit: You could also look at multi-source BFS [Breadth First Search] using a mask for non-traversable areas using Numpy
Interesting concept. I think I’ll take a swing at a pure python version for pyRevit. And get rid of the need for family dependency. Think is would be more flexible if it worked with rooms rather than floors.
Yes - but that’s my preferred toolset for something of this scale. pyRevit just makes deployment and documentation (help files) simpler to push out to the office. And generally much more robust error checking and UI/UX for the end user. Making aa prrogram that does X is one thing. Dealing with people using the program is another.
Here’s a working version in pyRevit (all python)
Basically the same as the dynamo version with a few tweaks for tetsting.
Select destination points > Run script > Select floor face
Changed to accept all valid units as input.
yeah cheers could you show the codes here. for us there dont know pyrevit without github download…here is i for Dynamo. Forum.. and i am sure we can do the same in dynamo…maybe just another way
This is a demo of the VASA based solution I mentioned before, processing all portions of the traversable space (including stairs) across the entire project.
Sadly I can’t distribute the graph, but it’s pretty basic VASA use based on the tools therein.
This is kind of doing that, treating the egress stairs as the fire separation points.
The key piece (and why this feels slow on the first run) is not just utilizing the room geometry, as everything else is what gets you ‘traversable’ space (i.e. you can’t walk directly under the stairs without sufficient headroom); where you can’t fit between an opening, etc.). So you have to extract geometry of all classes which can obstruct egress which can take a bit. From there the voxelization should go pretty smoothly.