Recursive component

I am trying to create a topography by offsetting contour lines vertically and horizontally, each by a set factor (Is that recursive?). I think this is easy but I have forgotten, maybe.
And then potentially to use a graph to help generate this interval, where I could use x and y as x and z (si its like a section).
Any thoughts?

Hi @Julian_Raxworthy,

I guess this would rather be an iterative approach, since you are looping through your contour lines, one by one, and applying a set factor to each of them, in order to perform the offset.

For a recursive approach, you would have to define a base case and a set of rules to reduce all the other cases, until the base case is met or the maximum recursion depth (number of recursions) is exceeded. It’s comparable to the ancient snake dragon Ouroboros, who ate his own tail, until it had devoured its head. :wink:

What do you mean by interval? An interval of offset values?
Do you want to remap x- and y-values to x- and z-values? If so where do these values come from?
Are you using vanilla grasshopper or scripting (Python, C#, etc.)?

Also, check this out. The guy explains how to generate random topographies in GH.

  1. Recursion is a thing where a Method calls itself (until an exit condition occurs). This for instance never exits:

public void TheRabbitHole(){
Print(“No way out”);

But if you use some public vars to control the loops then:

In Main: loop = 0; MaxLoops = maxLoops;

public int loop;
public int MaxLoops;

public void TheRabbitHole(){
Print(“No way out. But hope dies last [loop: {0}]”, loop);
if(loop>= MaxLoops) {Print(“Adios amigos”); return;}

  1. Offseting Curves IS VERY TRICKY. If you have a set of contours and you want to make some distorted (random or not) terrain … I would strongly recommend to forget offset: just get some div points (required: some proportional to the lengths N of divisions), distort them (any way you want) and then do a proper Ball Pivot mesh (a BP is not the Jack for all trades … but the pros are slightly more than the cons). DO NOT attempt Delauney on these points (D is good for flat [or almost flat] pt collections).

  2. If you have a BrepFace and you want to distort it then there’s other far smarter ways to do it (just FORGET curve offset): get the underlying Surface > divide (i.e get a pts Tree) > distort the pts (randomly maybe) > get the nurbs > get the inner/outer Loops (from the donor BrepFace) > project Loops > trim the new one (requires a way to know what to keep, mind) … blah, blah . For more freaky stuff you can use Morph Methods as well (Maelstrom is only for the very brave).

  3. If you have a Surface … well … that’s elementary > get the div pts > distrort > get the nurbs. If you want to viz the results get the contours (Avoid short paths at any cost [VERY slow]).

PS: Do you speak C#? That’s the critical question.