Rhino’s Python scripting capabilities allow you to generate complex organic shapes and forms. In this tutorial, we’ll walk through several methods to create an organic, wavy wall surface using Python in Rhino 7.
contents
Method 1: AddSineWave
The AddSineWave command in rhinoscriptsyntax lets you quickly generate a sine wave shaped surface.
- Open Rhino and start a new model.
- Open the PythonScript command box (right click in viewport and click PythonScript).
- Enter the following script:
import rhinoscriptsyntax as rs
amplitude = 5
frequency = 3
rs.AddSineWave(amplitude, frequency)
- Press enter to run. This will create a sine wave surface in the viewport with the specified amplitude and frequency.
- You can experiment with different values to get more exaggerated waves.
Method 2: Sampling and Offsetting Points
This method samples points on an existing surface, offsets them randomly, and generates a new wavy surface.
- Draw a rectangular surface in Rhino.
- Open the PythonScript command box.
- Enter the following script:
import rhinoscriptsyntax as rs
import random
surface = rs.GetObject("Select surface", rs.filter.surface)
pointcloud = rs.SampleSurface(surface, 100, 100)
for point in pointcloud:
x = point[0] + random.uniform(-5, 5)
y = point[1] + random.uniform(-5, 5)
z = point[2] + random.uniform(-5, 5)
point.X = x
point.Y = y
point.Z = z
rs.AddPoints(pointcloud)
- When prompted, select the rectangular surface. This will sample points, offset them randomly, and display the new wavy point cloud.
- To convert to a surface, add this line at the end:
new_surface = rs.AddPlanarSrf(pointcloud)
Method 3: Lofting Random CV Points
We can create a wavy surface by defining control points and lofting between them.
- Open the PythonScript command box.
- Enter the following script:
import rhinoscriptsyntax as rs
import random
points = []
for i in range(10):
for j in range(10):
x = i*10
y = j*10
z = random.uniform(0,10)
points.append([x,y,z])
surface = rs.AddNurbsSurface(points, 3, 3)
- This will generate a grid of random CV points and fit a smoothing surface through them.
Method 4: Rotating Mesh Vertices
Applying random rotations to a mesh creates irregularities.
- Draw a rectangle and convert it into a mesh.
- Open the PythonScript command box.
- Enter the following script:
import rhinoscriptsyntax as rs
import random
mesh = rs.GetObject("Select mesh", rs.filter.mesh)
for i in range(mesh.Vertices.Count):
a = random.uniform(-180, 180)
b = random.uniform(-180, 180)
c = random.uniform(-180, 180)
rs.RotateObject(mesh.Vertices[i], a, b, c)
surface = rs.AddPlanarSrf(mesh)
- Select the mesh when prompted. This will rotate the vertices randomly and generate a wavy surface.
Summary
These examples demonstrate some techniques for creating organic, uneven surfaces using Python scripting in Rhino. By using tools like randomization, noise, and sine waves, you can generate unique geometric shapes and forms algorithmically. The rhinoscriptsyntax library provides several useful commands for prototyping and experimentation.