// Hydrous Habitat
The goal of this script was to develop an iterative means to generate interior infrastructure for an aquarium. The script works by taking any vertical plane and then using its footprint to generate a laser cuttable undulating surface. The script is parametric in several ways. It firstly can take on any dimension as a starting point, and then the appropriate amount of u and v points can be decided to create an optimum effect. The generative portion of the script utilizes randomization to create a unique surface with every iteration.
The output is designed specifically to generate sufficient geometry to use 1/4” thick acrylic for fabrication. The output is immediately ready to be played out for nesting and cutting. See the video below to view the script in action.
HydrousHabitat_scripting demo from Dan Russo on Vimeo.
Code Follows:
import rhinoscriptsyntax as rs
import random
def CreateRibs():
# Get the surface object
surface_id = rs.GetObject("Select surface", rs.filter.surface)
if surface_id is None: return
# Get the number of rows
rows = rs.GetInteger("Number of rows", 2, 2)
if rows is None: return
# Get the number of columns
columns = rs.GetInteger("Number of columns", 2, 2)
if columns is None: return
# Get the domain of the surface
U = rs.SurfaceDomain(surface_id, 0)
V = rs.SurfaceDomain(surface_id, 1)
if U is None or V is None: return
points = []
count = rows,columns
objs = []
srfS = []
contourLine = []
contourSrf = []
point1 = (0,0,0)
point2 = (0,0,20)
path = rs.AddLine([0,0,0], [0,0,.25])
# Add the points
for i in xrange(0,rows):
param0 = U[0] + (((U[1] - U[0]) / (rows-1)) * i)
for j in xrange(0,columns):
param1 = V[0] + (((V[1] - V[0]) / (columns-1)) * j)
point = rs.EvaluateSurface(surface_id, param0, param1)
point[1] = point[1] - random.uniform(.5,1.75)
#print point
points.append(point)
rs.AddPoint(point)
newSurface = rs.AddSrfPtGrid(count, points)
crv1 = rs.DuplicateSurfaceBorder( newSurface )
crv2 = rs.DuplicateSurfaceBorder( surface_id )
objs.append(crv1)
objs.append(crv2)
bridge = rs.AddLoftSrf(objs)
srfS.append(surface_id)
srfS.append(newSurface)
srfS.append(bridge)
polySrf = rs.JoinSurfaces(srfS)
contourLine = rs.AddSrfContourCrvs( polySrf, (point1, point2), interval = .5 )
contourSrf = rs.AddPlanarSrf(contourLine)
for i in range(len(contourSrf)):
rs.ExtrudeSurface( contourSrf[i], path, cap = True )
rs.DeleteObjects(surface_id)
rs.DeleteObjects(newSurface)
rs.DeleteObjects(crv1)
rs.DeleteObjects(crv2)
rs.DeleteObjects(contourSrf)
rs.DeleteObjects(bridge)
rs.DeleteObjects(polySrf)
if __name__ == "__main__":
CreateRibs()