Curve Frame At

Hi All, Rhino 6 release 14 common . In some closed planar curves the method FrameAt passing the start point parameter gives a plane that is perpendicular to the plane of the curve. Why? See the attachment

curve frame at.3dm (283.2 KB)

  1. curve details

ID: 755d3d76-78f5-4c41-9c9c-7bada575ea00 (4393)
Object name: (not named)
Layer name: Predefinito
Render Material:
source = from layer
index = -1

Geometry:
Valid curve.
Closed NURBS curve
start = (0,5.25011e-17,-3.40095e-33)
end = (0,5.25011e-17,-3.40095e-33)
degree = 3
control points: non-rational, count=15 (1 duplicate)
knots: uniform (delta=1), domain = -12 to -0
clamped at start and end
Geometry UserData:
UserData ID: 3B7FB506-437C-431e-B1D7-93C4CBFF417F
Plug-in: Rhino
description: Gumball grip frame
saved in file: yes
copy count: 26

  1. curve details

ID: 68cd0fef-8028-451f-858d-3ed99783d522 (4373)
Object name: (not named)
Layer name: Predefinito
Render Material:
source = from layer
index = -1

Geometry:
Valid curve.
Periodic NURBS curve
start = (0,-5.4255,-0.160673)
end = (0,-5.4255,-0.160673)
degree = 3
control points: non-rational, count=23 (3 duplicates)
knots: uniform (delta=0.927178), domain = -18.5436 to -0
Geometry UserData:
UserData ID: 3B7FB506-437C-431e-B1D7-93C4CBFF417F
Plug-in: Rhino
description: Gumball grip frame
saved in file: yes
copy count: 8

Hi @gianfranco74,

This code seems to product the correct result?

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

id = rs.GetObject("Select curve", rs.filter.curve)
if (id):
    curve = rs.coercecurve(id)
    if curve:
        t = curve.Domain.Min
        pt = curve.PointAt(t)
        sc.doc.Objects.AddPoint(pt)
        rs.AddPoint(pt)
        rc, plane = curve.FrameAt(t)
        dom = Rhino.Geometry.Interval(0.0, 1.0)
        srf = Rhino.Geometry.PlaneSurface(plane, dom, dom)
        sc.doc.Objects.AddSurface(srf)
        sc.doc.Views.Redraw();

Perhaps we need to see your code?

– Dale

Hi Dale, thank you. I use c# and rhino common. my piece of code takes the 2 curve from the 2 ids with a get point, from objref or from rhobj. then I take the Plane with “curve. FrameAt(t, out Plane)”. now I am not in my office, tomorrow I will send the exact code.

I did the plane for the 2 curves that i sent to you the first time and it worked also form me(i did not understand why???) so i did a copy of the 2 curves and i tried again to see if i was crazy and you can see the result in the following shot: i did it with the following command

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gx = new Rhino.Input.Custom.GetObject();
            gx.SetCommandPrompt("Select curves");
            gx.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
            gx.GetMultiple(1, 0);
            if (gx.CommandResult() != Rhino.Commands.Result.Success)
            {
                return Result.Failure;
            }
            var objrefs = gx.Objects();
            for (int i = 0; i < objrefs.Length; i++)
            {
                var objref = objrefs[i];
                var curva = objref.Curve();
                if (curva == null)
                {
                    continue;
                }
                Rhino.Geometry.Plane piano;
                double t;
                curva.ClosestPoint(curva.PointAtStart, out t);
                //t=curva.Domain.Min   as you want, i tried both
                if(!curva.FrameAt(t, out piano))
                {
                    continue;
                }
                var dom =new  Rhino.Geometry.Interval(0.0, 1.0);
                var srf = new Rhino.Geometry.PlaneSurface(piano, dom, dom);
                Rhino.RhinoDoc.ActiveDoc.Objects.AddSurface(srf);
                Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
            }
            return Result.Success;
        }

curve frame at 001.3dm (73.8 KB)

I am testing some curves and i saw that if they are periodic they can give strange results. i will post something better as soon as i finish testing

I repeated the command with 60 sections more or less and i am not able to understand the bug(because i can only think it is a bug). the planes depends on where the sections are. if a translate the same sections and i repeat the creations of the planes at the starting point sometimes they are wrong, some others they are ok but in a random way.

Hi @gianfranco74,

Curve.FrameAt returns a plane based on the curve’s tangent and curvature vectors at a given parameter. If the curvature is really small at a given parameter, then you can end up with a vector that is basically noise. In this case, best to use Curve.TryGetPlane, if the curve is planar. If the curve is not planar, then use Curve.PerpendicularFrameAt and orient the output plane to your liking.

– Dale

1 Like

Ok , Thank you very much Dale for your help.