Offset multiple Splines in the right direction

Hi good morning I’m trying to create a pipeline which brings in a bunch of ‘legal boundary’s’ these are all splines from CAD, someone has already created these, they are closed splines and are layered individually to the ‘plot’ to which they are assigned. this is a lot of work someone has done and I want to reuse it.

‘all’ I need to do is offset all the splines by 0.25m outwards, i’ve tried this in 3dsMax however I can’t normalize the splines some go in, some go out. is there a way to -

Offset each spline to face the same direction as the others

  • Retain the layer in which the original was from and assign it to the new? ie plot 001 offset out, that gets assigned to plot layer 001.
  • Delete the orginal.

I’m assuming this might work with grasshopper but I’m a bit of a novice with it. any help would be amazin thankyou

It sounds relatively easy with Gh but we need a file.

wow that was a fast response, please see link to rhino file with DWG’s - Unique Download Link | WeTransfer

I wondered if there wasn’t an easy way to normalize the splines perhaps there could be an area comparison, is it larger than the original Yes =- worked correctly, is it smaller than original then failed and requires ‘normal flip’

please note that in your file this curve is not closed, there are 2 separate curves and they both lie on layer Plot 48 (so they will generate 2 separated offsets, and it will probably be incorrect):

something like this should work (assuming all your curves are closed, and you are on Rhino 8):


replace_closed_crv_with_its_longest_offset.gh (13.4 KB)

it will replace each curve on each layer with its external (longer) offset

I have tried 3 ways: the native, the loose and Clipper

The latter is most trustworthy and outputs everything outwards at once, no need to produce the negative offset for comparison.

You have two problematic curves that, under some circumstances, may generate wrong result.

Boundarytest.3dm (1.4 MB)

Updated with layer assignment. I have put OLD and NEW markers on the objects, just in case.

Incredible response from you both thank you so much! I’m currently on site and will check when I am back. I am using rhino 6 tho so guessing some of this might not be possible with my version?

Saved as V6

Boundarytest.3dm (1.4 MB)

yep, sorry for that, mine is entirely based on R8 new GH components

I guess there could be ways to do that in R6 with custom code (or even Elefront maybe)

manually fix open curves first:
_selOpenCrv

afterwards:
i think the best approach is to use a script(ing)-component and use
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.curve/closedcurveorientation

combined with conditional use of:

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.curve/reverse

to make sure all curves are Counter-Clock-Wise

then numeric offset should do the job

    private void RunScript(Curve crv, ref object crvCCW, ref object crvBad)
    {
        crvCCW = null;
        crvBad = null;
        Curve workingCrv = null;
        bool success = true;
        CurveOrientation crvOrientation = crv.ClosedCurveOrientation(Vector3d.ZAxis);
        success = crv.IsClosed && crvOrientation != CurveOrientation.Undefined;
        if (success)
        {
            workingCrv = crv.DuplicateCurve();
            if (crvOrientation == CurveOrientation.Clockwise)
            {
                success = workingCrv.Reverse();
            }
        }
        if (success)
        {
            crvCCW = workingCrv;
            return;
        }
        crvBad = crv;
    }

not sure how to get this backward = rh6 compatible.
this file is the rh8 version:

offset_CCW_crvs.gh (7.2 KB)

hope this helps - kind regards -tom