Trim excess curves and make it into one close curves

Hello, I need help in trimming the excess curves of the offseted curve. I’m trying to do it in a ghpython code however I’m still not achieving what I wanted to do. Is there any way to do achieve this goal?

TRIM CURVES.gh (7.0 KB)

Join them first?

1 Like

Using the Vipers components by Tang Chi:


TRIM CURVES_re.gh (9.2 KB)

P.S. The C# source-code is on Github, so maybe you can learn something from there.

You could use this method (edit: You probably need to use Extend Curve to make sure the lines intersect for that to work though).

But also, you could do the polyline segment offsetting and intersecting/trimming the resulting lines in GhPython. I have a fairly simple function for that I can post when I’m back on my laptop, if you’re interested.

Here’s a quick implementation, I expanded the function to take variable distances along the polyline segments:

Also note that this was written to offset many polylines at once, hence the explicit looping/Grasshopper types, which helps with performance.

Edit: Forgot to upload the file:
241015_OffsetPolylinesVariableDistance_Anders_00.gh (7.4 KB)

2 Likes

hi! Thank you for this! This works perfectly

1 Like

It is possible to make this script to work also with curves? Quite useful script but I do have a lot of of rounded curves and there this script it is not working. Thank you.

I mean, I’m no programmer, but if I had to approach this problem using vanilla Grasshopper, this would be passable solution:


variable polyline offset.gh (29.7 KB)

I just don’t know how you would identify and cull the inadmissable polylines. Maybe like this?:


variable polyline offset2.gh (27.1 KB)

Something tells me though, that this won’t hold up to scrutiny. How is this problem approached from the programming side?


?

I’m not sure what you mean about scrutiny, but the component documentation clearly states that it does not support clipping.

I see. Thank you. By scrutiny, I mean my script, not yours.

1 Like

The script was developed specifically for fast/reliable offsetting of polylines (i.e. using basic vector methods and line intersections), so curves would require a different logic (e.g. using the native curve offsetting function for each polycurve segment, and then trimming these afterwards).