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.
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:
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:
#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)
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: