Python offset

I am trying to offset a curve, but when pushing the offset to far it tangles within itself. As shown with the blue in the second picture I want the line to go around it and ignore or merges ‘gaps.’

Do you know what I am doing wrong?

This is part of a larger script I am working on, so I am not looking for components alternatives.
Thanks in advance for your response. :slight_smile:

20190118 problem python offset 00.gh (7.7 KB)

Hello @ForestOwl,

You’re not doing anything wrong per se, however it matters where your reference point is placed within your closed curve. It seems to me that it can’t be placed too close to the gap! I don’t exactly know why, though.

However, you could come up with a recursive function or something similar that would spawn a random point inside your closed curve, use it to perform the offset, check if the area of the offset curve is bigger, than the area of your initial curve, and returns the offset curve, if the condition is met.
If the area of the offset curve is smaller than the area of the initial curve, you know that something went wrong and so does the function. It calls itself, spawns a new random point, offsets the initial curve and so fourth, until a satisfying result is met.

1 Like

Hi,
I think you need to pick the longest length from a reasonable range of points, but that will not necessarily be longer than the starting curve if a lot of inlets are being cut off.

1 Like

20190118 problem python offset 00.gh (8.7 KB)
offset

My code uses Rhino.Geometry instead of rhinoscriptsyntax and it doens’t have this problem.

Input: Crv(curve), D(offset value)
Output: C (offset to outside), H(offset to inside)

2 Likes

Thank you guys! :smiley: