For that, I wrote a Python script but I don’t see how to modify the knot vectors (I can insert values but not remove them, the function rs.RemoveSurfaceKnot returns “False”, maybe because I don’t give the right values).
import copy
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
for i in range(len(points)):
points[i] = rs.coerce3dpoint(points[i])
surface = rg.NurbsSurface.CreateFromPoints(points, uCount, vCount, uDegree, vDegree)
for k in surface.KnotsU:
rs.RemoveSurfaceKnot(surface, (k, 0), False)
for k in surface.KnotsV:
rs.RemoveSurfaceKnot(surface, (0, k), True)
for k in knotsU:
surface.KnotsU.InsertKnot(k)
for k in knotsV:
surface.KnotsV.InsertKnot(k)
for k in surface.KnotsU:
print(k)
The “print” display the new inserted values with previous values that I can’t remove.
I try it but without success.
In my case, surface.KnotsU is the vector [0, 0, 0, 0, 1, 2, 2, 2, 2] (9-size) and I want to put the vector [0, 0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1, 1] (11-size).
The number of knots is not free to choose, this depends on the surface degree and number of control points: nKnots = nControlPoints + degree - 1
So if you want to have a U-knot vector of length 11, you need to add two more control point rows in the surface U-direction. This is easiest done by calling InsertKnot, as that will add new and modify existing control points to keep the surface shape the same with more control points.
Yes of course but I have 6x6 grid points with degree of 4 for u and v, so 11-size for knot vectors, so I don’t understand why the size is 9. nurbs_surface.gh (10.0 KB)
Here is my GH file, it can help.
I think you have come across a difference between the opennurbs convention of number of knots and the number of knots that is used in many textbooks on NURBS and other programs. opennurbs does not have what is called “superfluous” knots. For more info see Rhino - Superfluous Knots
Now, what is the reason you want to have [0, 0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1, 1], can you tell me more so I can understand what problem it is you’re trying to solve.