Can I get an example, please?
I’ve been looking at this example (on the bottom of the page):
Also, looking through the API: (NurbsSurface — rhino3dm 8.4.0 documentation)
There seems to be no SET functions only GET functions.
Also:
KnotsV.Count → no function Count
KnotsU.Count → no function Count
Here’s my unsuccessful attempt to translate this in CPython (rhino3dm)
def TST(is_rational = None, dim = None, u_degree = None, v_degree = None, u_cv_count = None, v_cv_count = None, u_knot = None, v_knot = None):
if is_rational == None:
is_rational = False
if dim == None:
dim = 3
if u_degree == None:
u_degree = 2
if v_degree == None:
v_degree = 3
if u_cv_count == None:
u_cv_count = 3
if v_cv_count == None:
v_cv_count = 5
# make up a quadratic knot vector with no interior knots
if u_knot == None:
u_knot = [0.0, 0.0, 1.0, 1.0]
# make up a cubic knot vector with one simple interior knot
if v_knot == None:
v_knot = [0.0, 0.0, 0.0, 1.5, 2.0, 2.0, 2.0]
# Rational control points can be in either homogeneous
# or euclidean form. Non-rational control points do not
# need to specify a weight.
CV = dict(((i,j),None) for i in range(2) for j in range(3))
#print(CV)
for i in range(0, u_cv_count):
for j in range(0, v_cv_count):
CV[i,j] = rhino3dm.Point3d(i, j,0)#i-j
# creates internal uninitialized arrays for
# control points and knots
nurbs_surface = rhino3dm.NurbsSurface.Create(dim, is_rational, u_degree + 1, v_degree + 1, u_cv_count, v_cv_count)
# add the knots
for i in range(0, len(nurbs_surface.KnotsU)):
nurbs_surface.KnotsU[i] = u_knot[i]
for j in range(0, len(nurbs_surface.KnotsV)):
nurbs_surface.KnotsV[j] = v_knot[j]
# add the control points
for i in range(0, nurbs_surface.Points.CountU):
for j in range(0, nurbs_surface.Points.CountV):
# SetControlPoint(self: NurbsSurfacePointList, u: int, v: int, cp: Point3d) -> bool
nurbs_surface.Points.SetControlPoint(i, j, Rhino.Geometry.ControlPoint(CV[i, j]))
if nurbs_surface.IsValid:
model = rhino3dm.File3dm()
model.Objects.AddSurface(nurbs_surface)
#sc.doc.Views.Redraw()
model.Write('test.3dm', 0)
else:
print('nurbs_surface.IsValid = False')
I’m a bit stuck here:
nurbs_surface.Points.SetControlPoint(i, j, Rhino.Geometry.ControlPoint(CV[i, j]))
SetControlPoint()
function doesn’t exist in rhino3dm and there’s no object rhino3dm.ControlPoint()
so I’m not sure what to do.