Turning windmills into nuclear plants

Hi everyone,

So I find myself a long way down a sinuous path and I’d like some advice.

It all began when I decided to clean up an old map on photoshop (bear with me).

The sea on this map was represented by coastal lines (like so), but it was so busted that I decided to redraw it. The first idea that poped to mind was to do it in rhino, redrawing the last coastal line by hand and offsetting it. As I was feeling the weight of doing that multiple dozens of time, I decided to see what I could cook up in grasshopper to automate this boring stuff. And we never know, such a definition might come in handy if I ever find another busted old map.

Here’s what I came up with:

and the result:

(sorry for the mess)

at the moment, the python script looks like this:



while step < z:

print (a)


step=step+1 “”" I know ‘step+1’ would be sufficient here"""

Is it possible to add the initial curves as a variable in the python node and integrate the Grasshopper reduce node and offset node inside the python script?

Something like this:



while step < z:

""" Simplifying the curve and offsetting it at every turn

curve = GH.reduce(curve) (tolerance=0.2)

curve = GH.offset(curve) (by ‘-a’) “”"



and just grab the resulting curve as the output from the python node?

And here’s where the title of the post comes into play: Have I gone way too far and could this be resolved in a simpler manner?

Thank you for your time!


Also yes.

Am I getting this right that you want to input a curve representing the coastline and then offset it numerous times to represent what is shown on the old map?

Yes, I would like to offset this curve many times (>20 at least), each time a bit further than the last offset distance to signify the depth of the water (the y in ’ a=a+(x+y) being that little bit).

Can you share an example file?

PolyCurve/PolyLine Offset (general case) is one of the most challenging tasks. Just try the GH Offset Curve thingy on some “unsuitable” Curves. Or get a random Curve and try to offset it 100 times inwards/outwards.

Here’s a good classic abstract publication on that matter:

anoffsetalgorithm.pdf (723.4 KB)

I could provide some indicative hints (The full working solution is strictly internal) but using C# and there’s no way to auto translate the code into P.

Continuing the discussion from Turning windmills into nuclear plants:

Coastal_lines.rar (3.5 MB)
Here are the files (3dm and gh).

I’ve realized that offsetting curves wasn’t an easy task (especially after working with archicad that struggles to offset anything ). In the file I’m working on, I couldn’t manage to offset it more than 3-4 times before it started self intersecting and going crazy. Thank you very much for the publication, I’ll give it a read!

Well … as I said the topic is big and ultra hot (most notably for CNC routing and the likes - where we don’t use Polylines for more than obvious reasons). If you are not in the advanced coding bandwagon OR this is just an one-off case … well … you can guess my suggestion.

I’m obviously not in the advanced coding bandawagon, I’ve been learning python for a few days now, without any background in programming (architect).

From a quick read of that paper on polyline offsetting, I can tell you that I’m in no way trying to solve this fundamental problem, just trying to save some time and learn something in the process. If I end up having to manually clean the last polyline every 3-4 offstets, it’s already a big win for me.

Getting back on the GhPython script, here’s what I came up with:

import ghpythonlib.components as gh

tolerance = 0.2
offsetNB = 0
distance = start
while offsetNB < length:

  • #Simplifying the curve and offsetting it at every turn
  • curve = gh.Reduce(curve,tolerance)
  • curve = gh.OffsetCurve(curve,-distance)
  • offset = curve* # offset as been set as the output of the GhPython node
  • distance = distance + (start + step)
  • offsetNB = offsetNB + 1

Now I’m struggling to create a list with all the ‘offset’ curves created; as is, I’m only getting the last one as an output.

And I’m getting some various error:
Warning: Offset Curve: Vicarious argument deduced from defaults at position 3. Add value for ‘corners’: ‘1’.
Warning: Offset Curve: input 1 curve. error: Data conversion failed from Integer to Curve
Warning: Offset Curve: solver component. error: Data conversion failed from Integer to Curve

Well … P is not my game (in fact I hate that thing) thus I can’t help you on your code. That said, writing a C# that does what you describe is very easy (but useless for you - not to mention the “quality” of the results).

But the big/main loophole here is that you are trying to “by-pass” a general strategy - say as exposed in the attached paper - on that topic (i.e. self ccx Events [it’s most unlikely that you can skip that], Loops/Islands and the likes) by using the Reduce Method. This may or may not work (obviously is Topology per case related: I never address ANY problem that way).

This is already looking pretty nuclear to me!
I can’t remember if the Bowerbird Offset uses the algorithm that @PeterFotiadis links to, but it’s pretty good in any case. Only thing is that it offsets open lines as “thick” lines, so I have taken the liberty of closing your example file, which you can trim after the offset (and simplify, if you wish)
bboffset.gh (17.3 KB)

Well … since hope dies last get a 2 minutes C# thingy that does 2 minutes thingies (i.e. crap).

Curve_Offset_HopeDiesLast_V1.gh (14.2 KB)

Moral: Long is the path (and hilly).

without using Bowerbird offset function (thanks for the discovery), I think I’m getting something:

import rhinoscriptsyntax as rs
import ghpythonlib.components as gh

offsetNB = 0
distance = start
offset = [ ]
offsetD = [ ]

while offsetNB < length:

#Simplifying the curve and offsetting it at every turn
curve = gh.Reduce(curve,tolerance)
curve = gh.OffsetCurve(curve,-distance)
len(offset) +1
offset = offset +[curve]
len(offsetD) +1
offsetD = offsetD +[distance]
distance = distance + step
offsetNB = offsetNB + 1

with the step value I chose, it does not fail after 10 steps, except for a weird thing happening near the bottom

Just butting in here to the conversation! Sorry, I can’t seem to get a Rhino 7 zoo licence to open your coastal file at the moment, but with those type of self-intersecting issues maybe as well as scripting it, try the polyline offset component in the NGon library: https://www.food4rhino.com/en/app/ngon . I’ve found it super reliable for offsetting polylines, you can adjust the divisions for curves at each iteration too. Here is a simple example with two input curves with concave bits for which the usual offset component fails:

Thanks! I’ll see what happens if I replace de gh component by this one.