Closing Topographical Contours With Boundary in Correct Direction

P-241_shadows.3dm (11.0 MB) (10.0 KB)

I’ve been wondering, in an attempt to further facilitate the workflow between survey and bioclimatic analyses, whether it would be possible to close topographical contours with a boundary line. this might be too arbitrary because I presume it’s hard to tell Grasshopper which side to close the conutour with the boundary intersection while preserving the integrity o fthe topography (ie. the correct direction) without selecting that manually for each contour? can’t sort boundary trims by legnth, distance or height, as those are arbitrary… :thinking:

I’ve done the initial work, ie. using a script (not included) to move the contours up to their correct height, making them fit/triiming to boundary extents and intersect with the boundary outlines.

(This is so that I have solid closed breps of each topographical layer in order to run shadow study for each topographical layer and then combine them :weary: unless someone knows how to perform the year’s soltice shadow studies of a terrain mesh on itself?)

Thanks in advance!


UPDATE: see my comment below.

This is not GH - because as you said, it’s difficult to tell topologically which side of the contour you want joined with the border. On top of that 2D contour maps can be completely ambiguous if there is no elevation data attached to the curves - you have no idea which way is “up” or “down”.

That being said, as in modelmaking we are often faced with the need for closed contours in order to cut material for physical models, I have a semi-automated script I developed which helps.

Script: (8.3 KB)

Tutorial PDF (English):
Closing contour curves for cutting_EN.pdf (244.7 KB)


Awesome! Will look through it! Thank you.

In the meantime, I think I found a way to tackle my problem, but I am stuck at trimming the boundaries at the end. I used the trimmed contrours to generate a 3D terrain. I wonder if now the terrain mesh/surface may be used to trim the boundaries at each respective height and then cull to chose only the boundary portions bellow the surface and join those with the contours?

Updated GH script attahced. (245.5 KB)

Wanted to give it a go, ended up with an overkill. (248.4 KB)
It calculates everything in something like 3 seconds.


  • extending Isopleths create problems, input curves should have a reliable status (already ending precisely at delimited area or all exceeding by a fixed amount, and not too much).
    Currently extending by 7, which is found to avoiding further errors by trial and error
  • you were missing 3 small Isopleths here:
    2021-03-16 17_56_19-P-241_shadows.3dm (11 MB) - Rhino 7 Commerciale - Perspective
  • datatree management is sort of tricky, in many steps i wondered if implementing “Hops” to simplify it all could have lead into a faster and better logic

Tomorrow i won’t be able to understand this definition, hope it is good.
Summarized steps are:

  • project base perimeter, make it a surface
  • round Isopleths altitude and group them by altitude
  • for each altitude level, shatter the base surface by the Isopleths and move the fragments at the proper altitude
  • (if you stop here, bake and manually delete unwanted fragments on rhino to have a MUCH simpler solution, more reliable for future situations. Click>Del>Click>Del>Click>Del>Click>Del…)
  • for each altitude level, create a branch containing Isopleths curves of “neighbor” levels (+1 and -1 , when it exist)
  • for each Isopleths find the nearest neighbor Isopleths, do a “ping-pong” to have a clean “steep” vector and flip the Isopleth curve so it have at its right side the downhill.
  • for each altitude level, make a sufficiently dense (this depends on how much your Isopleths are near to external perimeter, and how small will be resulting cuts) point divisions and move them a bit to the right of the curve
  • for each altitude level, for each surface fragment, discard each of them that have an intersection with vertical rays from the points of previous step.
  • have a headache



Thank you for taking the time Riccardo! I see it was totally reworked, much appreciated.