How to create a curve by specifying the point type: Point/Control Point?

Hi,

If I have a list of 6 Points, and also the Type for each point, as in the sketch below, how can I create a (poly)curve out of it ?

It might be a lot easier to make multiple curves and just join them? Then you can do a basic nurbs curve easily.

As far as I see it, what you suggest requires some programmatic list manipulation. A loop in which you create sublists for the multiple curves.

I’m wandering if there’s already a proper method already implemented.

when separated, some points become endpoints for a curve and startpoints for another.

What is the degree of the required the components of the polycurve?

Points 1, 2, 3 and 4 could be used as control points for a single span degree 3 curve.

I’ve done it by separating the polyline into multiple curves.

#reading Control Points

__author__ = "bogda"
__version__ = "2022.06.15"

import rhinoscriptsyntax as rs
import ghpythonlib.treehelpers as th

i=0

t_lists=[]
x_lists=[]
y_lists=[]

for i in range(0,len(t)):
    list=[]
    list_x=[]
    list_y=[]
    if t[i] == "OFFCURVE" and t[i-1] != "OFFCURVE":
        list.append(t[i-1])
        list_x.append(x[i-1])
        list_y.append(y[i-1])

        while t[i] == "OFFCURVE":
            list.append(t[i])
            list_x.append(x[i])
            list_y.append(y[i])
            i=i+1
        list.append(t[i])
        list_x.append(x[i])
        list_y.append(y[i])

        
    t_lists.append(list)
    x_lists.append(list_x)
    y_lists.append(list_y)


layerTreeX = th.list_to_tree(x_lists)
layerTreeY = th.list_to_tree(y_lists)
a = layerTreeX
b = layerTreeY

and

#Reading Points

__author__ = "bogda"
__version__ = "2022.06.15"

import rhinoscriptsyntax as rs
import ghpythonlib.treehelpers as th

poly_lists =[]
x_lists=[]
y_lists=[]

for i in range(0,len(t)-1):
    poly_list = []
    list_x=[]
    list_y=[]
    
    while t[i]=="CURVE" or t[i]=="LINE":
        list_x.append(x[i])
        list_y.append(y[i])
        i=i+1
            
            
            
    poly_lists.append(poly_list)
    x_lists.append(list_x)
    y_lists.append(list_y)


layerTreeX = th.list_to_tree(x_lists)
layerTreeY = th.list_to_tree(y_lists)
a = layerTreeX
b = layerTreeY

You have also the GH attached.
2022-06-16-BC-Glyphs-Reader.gh (26.5 KB)

@DavidRutten , would you be so kind to have a look? Maybe implement in GH2?
I wrote this to be able to read .glyph format, used in Typography Design to design letters and characters and transform them into fonts. There are other applications also.

Control points of degree 1 NURBS curves coincide with the knots of degree 1 NURBS curves and are on the curves.

The first and last control points of an open NURBS curve are always on the curve.

A polycurve is two or more individual NURBS curves joined.

It appears that all the points in the example could be considered as control points, with the difference being the degree of the curves.

so, you are suggesting another method?
There is no component in which I can specify the type. Or am I wrong?

I’m not fluent in Python. I also don’t use Grasshopper. Below is how I would approach this in general. Feel free to ignore.

I’ll make some assumptions.

  • The polycurve is a collection of single span NURBS curve (also known as Bezier curves).
  • “Points” are the ends of the individual single span curves.
  • The points and control points are in an ordered list.

Using these assumptions:

The “points” are also control points for the individual curves because they are are at the end of the curves.

The degree of equal single span curve equals
2 end points + number of interior control points between end points - 1
If there is not a “control point” between end points the degree is 1, a straight line
If there is 1 one “control point” between “points” the degree is 2
If there are 2 “control points” between “points” the degree is 3

Parse the “points” and “control points” into sets of input control points for the curve segments.
Note that a single end points may be used as an input control for two adjacent curves.

Calculate the degrees of the curve segments.

Use the NURBS Curve object in Grasshopper to create the individual single span NURBS curves using the sets of input control points and the curve degrees.

Join the individual curve segments into a single polycurve.

Yes, you are describing what my short code above does. With the exception that I assume a degree of 3 for all the nurbs. The thing is that I can write it in Python correctly, but I cannot imagine how to do this in Grasshopper. This is why I was asking David Rutten to have a look also… Thanks for the input!