Open Nest ununderstandable problem

Hi guys, I just want to unroll these parts and have them nested in sheets using OpenNest by @Petras_Vestartas @Petras1

but I keep getting this error no matter how I try to get around it. I checked out the example file and I think I’m following the workflow in the same manner, but it keeps giving me “Object ref not set to an instance of an object…”

I have uploaded an image of the .gh file and the .gh file itself along with the .3dm file. I appreciate any kind of help. Thank you.

Forum.3dm (7.3 MB)
OpenNest Problem.gh (10.0 KB)

It is because you are trying to nest some open curves. If you nest flat hex faces you get this:

1 Like

Thanks for the reply. Actually my curves were closed, but I found out that the problem is in curved curves. I have some curves that are not line-like. and when you use discontinuity and pline them you get polycurves that are all made up of line-like curves. does Open Nest not support curved curves?

In the end they become polylines, so if you have curves, you can subdivide them, nest them, and then orient curves to polylines by nested transform.

Hi @Petras_Vestartas, first of all, thanks for the OpenNest plugin. I am trying to nest curved curves with Rhino Plugin, not with Grasshopper version, it doesn’t seem to work. I guess it is because the plugin tries to convert curved curves to polyline but fails, interestingly I can nest the same curved curve with the Grasshopper version. Am I doing some usage mistakes? I need to use the rhino plugin version, thanks!

You are right curves are always converted to polylines. I suggest to use grasshopper in this case.

Do you have any plans on integrating curves as input directly? Because converting curved edges to polylines results in too many points and it may occur problems. I would be glad to help if you decide to make it opensource.

The issue is when user cannot control number of points as you would do in grasshopper during conversion. When you have tons of point for a single polyline the solver will hang looping forever. Thus you need either very a minimal amount of points or convex hull polyline.

The addition you describing needs to be done like that:
If you would like you could create a separate rhino command to convert curves to polylines by minimal amount of points. The main point is that this closed polyline must enclose fully the curve, elsewise you would have collisions in the final result (including concave and convex cases). Then I would include into next release. This was an idea behind grasshopper component RhinoObjects which is the same method applied in Rhino plugin. It groups outlines based on a logic that curve, lines and other object always are placed within a closed polygon. I do not know why the third case works, but it seems it would be enough just to have a closed polygon. You can see two guids. After nesting you would skip the polygon i.e. by hiding layer.

hmm, got it, I am going to think about that :+1: If I come up with a solution I will notify you. By the way, before the image update, I was going to request for contents of that block :slight_smile: I thought that you solved in Grasshopper but didn’t transform to RhinoCommon, it is clear now.

I thought so too, but I checked the code, it is the same stuff in both cases.

There are solutions as well:

But I think there could be a simpler and faster method just to get a low poly cage, since we are not dealing with points but already closed curves.

BoundingBox’s Inflate method would be nice here :slight_smile: Offset seems to work, I am testing it.

    internal static List<Guid> CreateConcaveHull(ObjRef[] refs)
    {
        List<Guid> hullGuids = new List<Guid>();
        var doc = RhinoDoc.ActiveDoc;
        foreach (var objref in refs)
        {
            Curve curve = objref.Curve();
            PolylineCurve l = curve.ToPolyline(1, 0, 0, 0);
            double offsetLength = 1.00;
            bool needsInflate = true;
            PolylineCurve dupPlyLineCrv;
            do
            {
                offsetLength += 0.05;
                dupPlyLineCrv = l.Duplicate() as PolylineCurve;
                curve.TryGetPlane(out Plane plane);
                Curve[] edges = dupPlyLineCrv.Offset(plane, offsetLength, doc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.Sharp);
                dupPlyLineCrv = edges[0].ToPolyline(0.01,0,0,0);
                CurveIntersections intersections = Rhino.Geometry.Intersect.Intersection.CurveCurve(curve, dupPlyLineCrv, doc.ModelAbsoluteTolerance, doc.ModelAbsoluteTolerance);
                if (intersections.Count > 0) needsInflate = true;
                else needsInflate = false;
            } while (needsInflate);
            Guid guid = RhinoDoc.ActiveDoc.Objects.Add(dupPlyLineCrv);
            hullGuids.Add(guid);
        }
        return hullGuids;
    }
1 Like

Nice method.
The issue with curve to polyline conversion is that it will subdivide by curvature.
So that was my concern. In grasshopper user can set resolution if you subdivide by number and then offset the curve by clipper. But how to properly choose the subdivision value in Rhino since there is no interface? It also relates to scale the bigger the figure the more points this method outputs (for circle no but the figure on the right has 2x times more points than the smallest one):

PolylineCurve l = curve.ToPolyline(1, 0, 0, 0);

1 Like

I was thinking about that while coding the method :slight_smile: We should find some “sampling” ratio related to the length or something else.

Curve Length / 500 ratio gave some good results.

            double curveLength = curve.GetLength();
            double tolerance = curveLength / 500;
            PolylineCurve l = curve.ToPolyline(tolerance, 0, 0, 0);