Intro to Python Scripting: 22 Divide Surface to Pts

Software: 
Tag: 
Video Duration: 
6 minutes
Author: 
Zach Downey

In this quick tutorial we divide a surface up into points using python. This is a really quick tutorial, but is useful because it shows one way to reparameterize a surface using python. 

import rhinoscriptsyntax as rs
 
srf = rs.GetObject("Pick surface to divide")
udiv = rs.GetInteger("Number of Divisions in U",10)
vdiv = rs.GetInteger("Number of Divisions in V",10)
 
u = rs.SurfaceDomain(srf,0)
v = rs.SurfaceDomain(srf,1)
print(str(u))
print(str(v))
 
pts = []
 
 
for i in range(0, udiv+1, 1):
    for j in range(0, vdiv+1, 1):
        pt = (i/udiv,j/vdiv,0)
        srfP = rs.SurfaceParameter(srf,pt)
        newpt = rs.EvaluateSurface(srf,srfP[0],srfP[1])
        pts.append(rs.AddPoint(newpt))

Rating

Please rate this tutorial below. Thanks.

5
Average: 4.7 (12 votes)

Want to Contribute?

Want to be an author? Drop us a line here we'd love to have you.

Already have a video you'd like to post? Send us a link and we'll get you going.

:)