Hi everyone,
I wonder why the rhinoscript “CurvePointCount” method doesn’t return the right number of points on closed curves:
A closed curve with a kink at the start/end returns 1 point too much
A closed curve smooth all around returns 3 points too much

What is the reason for this and how can I obtain the correct point count?

If you use Rhino’s What command, you’ll see that Rhino.CurvePointCount is returning the correct value.

But the ExtractPt command does not extract every control point. If it did, you’d end up with duplicates in cases where you have closed and periodic curves.

My VBScript is a big rusty. But this is basically what the ExtractPt does.

Option Explicit
Call ExtractPt()
Sub ExtractPt()
Const rhCurve = &h4
Dim strCurve, arrPoints, i
Dim nCount, nFirst, nLast, nDegree
strCurve = Rhino.GetObject("Select curve for point extraction", rhCurve, True)
If IsNull(strCurve) Then Exit Sub
arrPoints = Rhino.CurvePoints(strCurve)
If Not IsArray(arrPoints) Then Exit Sub
nCount = UBound(arrPoints)
nFirst = 0
If Rhino.IsCurveClosed(strCurve) Then
nlast = nCount - 1
Else
nLast = nCount
End If
If Rhino.IsCurvePeriodic(strCurve) Then
nDegree = Rhino.CurveDegree(strCurve)
nFirst = CInt(nDegree / 2)
nLast = nCount - nDegree + nFirst
End If
For i = nFirst To nLast
Call Rhino.AddPoint(arrPoints(i))
Next
End Sub

Thanks Dale!
I still don’t know really why there is a difference in the number of points you get when you turn on control points, or why some of the points are duplicated, but I can life with that lack of knowledge (for now)