Class Practice Five – Parametric Surface

 

This is the fifth in-class practice doing a parametric surface using operations on 3D elements in Rhinoceros.

Here is the Python Code:


import rhinoscriptsyntax as rs
import math as m

surfX = 5.0
surfY = 5.0
surfHeight = .25

rs.DeleteObjects (rs.AllObjects ())
rs.EnableRedraw (False)

nrPtsX = 20
stepX = surfX / nrPtsX

nrPtsY = 20
stepY = surfY / nrPtsY

curves = []

for j in rs.frange (0,surfY,stepY):
    points = []
    for i in rs.frange (0,surfX,stepX):
        #z = m.sin (i*m.pi*2)*surfHeight*j
        z = m.sin (i*m.pi*2)*m.sin (j*m.pi*2)*.1
        #z = m.sin (i*m.pi*2)*m.sin (j*m.pi*2)*surfHeight
        points.append(rs.AddPoint ([i,j,z]))
        
    #rs.AddCurve (points)
    curves.append(rs.AddCurve (points))
    rs.DeleteObjects (points)

rs.AddLoftSrf (curves)
rs.DeleteObjects (curves)

rs.EnableRedraw (True)

surface = rs.GetObject ("Please select surface")

#U=horizontal=0 / V=vertical=1
domainU = rs.SurfaceDomain (surface, 0)
domainV = rs.SurfaceDomain (surface, 1)
print domainU

nrSpheresU = 5
nrSpheresV = 7

spheres = []

for j in rs.frange (0.5/nrSpheresV,1,1/nrSpheresV):
    for i in rs.frange (0.5/nrSpheresU,1,1/nrSpheresU):
        uParam = domainU[1]*i
        vParam = domainV[1]*j
        point = rs.EvaluateSurface (surface, uParam, vParam)
        spheres.append (rs.AddSphere (point, .1))
        
        
thickness = 0.05
extrusionCurve = rs.AddLine ([0,0,0],[0,0,thickness])
wall = rs.ExtrudeSurface (surface, extrusionCurve)
rs.BooleanDifference (wall, spheres)

Leave a Reply

Your email address will not be published. Required fields are marked *