Gradient Patterns
It’s been a while I’ve played with Grasshopper. It is getting to be more and more powerful. I think I will be exploring more in this world of Grasshopper + VB.NET and also IronPython included in the upcoming Rhino 5. This definition is super simple. It arrays / deforms a component that you define according to the two surfaces and their UV divisions.
In order to use the definition, first define a box, and some geometries within the box as your base component. Then, simply create two surfaces as references for organizing your components. Finally, control U/V divisions.
This is a rhinoscript where you can set various points where vectors flow out from according to a certain velocity. As these vectors travel, the flows are attracted to the various attractor points in different weights three dimensionally. It simulates a close logic to the emitted particles being attracted to newton forces in Maya.
—-
Option Explicit
‘Script written by Howard Jiho Kim / crtl-i.com
Call Main()
Sub Main()
Dim startPt, velocity
velocity = Array(10,0,0)
startPt = Rhino.GetObjects(“Select Start Points”,1)
‘Attractors / Distances
Dim no_attr, attr, attrStr, i
no_attr = Rhino.GetInteger(“How many attractors?”)
ReDim attr(no_attr-1), attrStr(no_attr-1)
For i=0 To no_attr-1
attr(i) = Rhino.GetObject(“Select Attractor ” & (i+1),1)
attrStr(i) = Rhino.GetReal(“Enter Strength for Attractor ” & (i+1))
Next
For i=0 To Ubound(startPt)
Flow velocity, startPt(i), no_attr, attr, attrStr, 35
Next
End Sub
Function Flow(velocity, startPt, no_attr, attr, attrStr, gens)
Dim vec1, vec0
vec1 = Rhino.VectorCreate(velocity, Array(0,0,0))
vec0 = Rhino.VectorCreate(Rhino.PointCoordinates(startPt), Array(0,0,0))
Dim totalDistance, distance, i
ReDim distance(no_attr-1)
Dim vec, finalVec, vec4, tagStop
tagStop = 0
ReDim vec(no_attr-1)
Dim newPt, newLine, endPt2
totalDistance=0
If gens>0 Then
For i=0 To no_attr-1
distance(i) = Rhino.Distance(Rhino.PointCoordinates(startPt), Rhino.PointCoordinates(attr(i)))
totalDistance = totalDistance + distance(i)
Rhino.Print distance(i)
Rhino.Print totalDistance
If distance(i) < 1 Then
gens = -1
End If
Next
‘Vectors
vec4 = vec1
For i=0 To no_attr-1
vec(i) = Rhino.VectorCreate(Rhino.PointCoordinates(attr(i)), Rhino.PointCoordinates(startPt))
vec(i) = Rhino.VectorUnitize(vec(i))
vec(i) = Rhino.VectorScale(vec(i), (attrStr(i)/distance(i))^2)
vec4 = Rhino.VectorAdd(vec4, vec(i))
Next
finalVec = Rhino.VectorUnitize(vec4)
finalVec = Rhino.VectorScale(finalVec, 1)
If tagStop = 0 Then
newPt = Rhino.AddPoint(finalVec)
newLine = Rhino.AddLine(Array(0,0,0), finalVec)
endPt2 = Rhino.MoveObject(newPt, vec0)
newLine = Rhino.MoveObject(newLine, vec0)
End If
Flow velocity, endPt2, no_attr, attr, attrStr, gens-1
End If
End Function
Some facade studies. All these patterns are made through a version of script that is very close to the 3D-pixelate code.

This is a script that pixelates point clouds into a user-defined 3-dimensional grid. It also arrays same size boxes to the pixelated points. If used wisely, it could become a good tool to rationalize a nurb surface into many small boxes.
![]()
It first pixelates the points into a wanted grid. Naturally, the geometry starts to lose its shape as the pixelating factor grows.

Then it populates the points with a box that you define.
—–
Option Explicit
‘Script written by Howard Jiho Kim / crtl-i.com
Sub Pixelate
Dim strObject, arrPoint, arrObjects, box_pt(7), box
arrObjects = Rhino.GetObjects(“Select points to pixelate”)
Dim multiplier_x, m1_x, m2_x, finalHeight_x, arrEnd(2)
multiplier_x = Rhino.GetReal(“Enter Pixelating Factor for X axis (0 for Non-Pixelation): “)
Dim multiplier_y, m1_y, m2_y, finalHeight_y
multiplier_y = Rhino.GetReal(“Enter Pixelating Factor for Y axis (0 for Non-Pixelation): “)
Dim multiplier_z, m1_z, m2_z, finalHeight_z
multiplier_z = Rhino.GetReal(“Enter Pixelating Factor for Z axis (0 for Non-Pixelation): “)
Dim box_yn
box_yn = Rhino.GetInteger(“Create boxes? (1-Yes, 2-No)”)
If box_yn = 1 Then
Dim box_x, box_y, box_z, box_mid_pt(2)
box_x = Rhino.GetReal(“Enter Box size-x: “)
box_y = Rhino.GetReal(“Enter Box size-y: “)
box_z = Rhino.GetReal(“Enter Box size-z: “)
box_pt(0) = Array(0,0,0)
box_pt(1) = Array(box_x,0,0)
box_pt(2) = Array(box_x,box_y,0)
box_pt(3) = Array(0,box_y,0)
box_pt(4) = Array(0,0,box_z)
box_pt(5) = Array(box_x,0,box_z)
box_pt(6) = Array(box_x,box_y,box_z)
box_pt(7) = Array(0,box_y,box_z)
box_mid_pt(0) = box_x/2
box_mid_pt(1) = box_y/2
box_mid_pt(2) = box_z/2
box = Rhino.AddBox(box_pt)
End If
If Not IsNull(arrObjects) Then
For Each strObject In arrObjects
arrPoint=Rhino.PointCoordinates(strObject)
Rhino.Print Rhino.Pt2Str(arrPoint, 3)
If multiplier_x > 0 Then
m1_x = arrPoint(0) / multiplier_x
m1_x = Rhino.Floor(m1_x)
m2_x = (arrPoint(0) – (m1_x*multiplier_x))*2
If m2_x > multiplier_x Then m1_x = m1_x+1
finalHeight_x = m1_x * multiplier_x
arrEnd(0) = finalHeight_x
ElseIf multiplier_x=0 Then
arrEnd(0) = arrPoint(0)
End If
If multiplier_y > 0 Then
m1_y = arrPoint(1) / multiplier_y
m1_y = Rhino.Floor(m1_y)
m2_y = (arrPoint(1) – (m1_y*multiplier_y))*2
If m2_y > multiplier_y Then m1_y = m1_y+1
finalHeight_y = m1_y * multiplier_y
arrEnd(1) = finalHeight_y
ElseIf multiplier_y=0 Then
arrEnd(1) = arrPoint(1)
End If
If multiplier_z > 0 Then
m1_z = arrPoint(2) / multiplier_z
m1_z = Rhino.Floor(m1_z)
m2_z = (arrPoint(2) – (m1_z*multiplier_z))*2
If m2_z > multiplier_z Then m1_z = m1_z+1
finalHeight_z = m1_z * multiplier_z
arrEnd(2) = finalHeight_z
ElseIf multiplier_z=0 Then
arrEnd(2) = arrPoint(2)
End If
Rhino.MoveObject strObject, arrPoint, arrEnd
If box_yn = 1 Then
Rhino.CopyObject box, box_mid_pt, arrEnd
End If
Next
If box_yn = 1 Then
Rhino.DeleteObject box
End If
End If
End Sub
Pixelate
I recently purchased a book which turned out to be one of the most amazing books I have ever come across: “A New Kind of Science” by Stephen Wolfram. The entire book is available online for viewing at: http://www.wolframscience.com/nksonline/toc.html
I have been reading a chapter on randomness, which is why I have been writing scripts that heavily depends on random number generator. These are the results of a growth algorithm that explores a territory that is somewhere in between being random and ordered.
A new script that I have been writing based on a script found in:
http://ncertainties3.wordpress.com/explicit-protocols/adam/181008_weldedwire/
The script diffuses any curve into smaller pieces of lines depending on a few parameters.
Merry Christmas, btw :)
Some tests: