Surface from points

In the below code"panel = rg.NurbsSurface.CreateFromPoints(cpts,2,vnum2,2,2)", I want to generate a surface with 1 degree from points. But now, I get a wrong thing.
Thx for ur help!


import random as rnd
import Rhino.Geometry as rg

uinc = 1/unum
vinc = 1/vnum

panels = []

for i in range(unum):
    for j in range(vnum):
        vlen = rnd.randint(1,10)
        if j + vlen > vnum:
            vlen = vnum - j
        cpts = []
        depth = rnd.randint(0,1)
        for k in range(vlen+1):
             cpts.append(srf.PointAt(i*uinc, (j + k)*vinc))
             cpts.append(srf.PointAt((i+1)*uinc, (j + k)*vinc))
        vnum2=int(len(cpts)/2)
        panel = rg.NurbsSurface.CreateFromPoints(cpts,2,vnum2,2,2)
        panels.append(panel)

a = panels

@daizhuo,

some variables are missing in your script. If i add them (unum=10, vnum=10) and add a surface as srf i can see that the points used in CreateFromPoints() seem not to be in the correct order. Can you show a picture or file of what you are trying to get as result from your script ?

c.

Thx for ur attention! I want to make this.

@daizhuo,

i´ve just changed this line:

panel = rg.NurbsSurface.CreateFromPoints(cpts, vnum2, 2, 2, 2)

note that for degree 1 surfaces, the last numbers should be set to 1 too.

daizhuo.py (1.1 KB)

c.

Wow! You’re so great! It works! Thank you so much!