Pratt | Digital Futures Group

Icon

Benjamin Ferraioli (Dragana + Onur)

script-board-blog10

Tags: Dragana, Ferraioli, Onur Gun, Rhino3D, Rhinoscript, Scripting

kristin koslowski (dragana + onur)

koslowski_learning-unit-sectionslearning-unit-sectionspattern development

Tags: Dragana, Koslowski, Onur Gun, pattern development, Rhinoscript

Student Scripts | babko_rossi

babko_rossi screenshot

babko_rossi_090219_ababko_rossi_090219_bbabko_rossi_090219_cbabko_rossi_090219_d

Three very similar variations on a script written for Babko and Rossi in Richard Sarrah’s class.  These scripts create a truss-like 3d pattern, with increasingly complex math-driven variations.  They rely on 4 methods to do the bulk of the work, described below.  3dm files which explain weaving are attached.

babko_rossi_iterations.3dmbabko_rossi_geomdef.3dm

the function DrawTetraMatrix, …

the function tetraPostProcess, …

the function Main, …

the function tetraGridPts

the function tetraCellPtsA, …

the function tetraCellPtsB, …

Tags: Rhinoscript, structure, student script, tiling, truss, two module

Abbe_Bernal | Screenshots

Script_A  : Produces a field of the module that does not change

Script_B : Produces a field of the module where the square get larger as they move closer to the middle

Script_C : Produces a field of the module where the thickness shanges according to a triple hump sin curve in the x direction and a single humo sign curve in the y direciton

Tags: abbe, bernal, field, Rhinoscript

Student Scripts | abbe_bernal

abbe_bernal_090216_a

abbe_bernal_090216_b

abbe_bernal_090216_c

Three very similar variations on a script written for Abbe and Bernal in Lonn Comb’s class.  These scripts create a truss-like 3d pattern, with increasingly complex math-driven variations.  They rely on 4 methods to do the bulk of the work, described below:

the function HynetCellPts, creates a collection of four points which makeup the basic module of a truss… it doesn’t draw anything to rhino, it just creates the points (as data) at a given location, and stores these points in an array.

the function HynetGridPts, calls upon this previous function, and creates a grid of modules at a particular scale and spacing…. again, it doesn’t draw anything, it simply creates the points and stores them in an array in a structured manner.  can you figure out the structure of this array, and draw it in monkeybrainland?

the function Main, calls upon this previous function, and creates two grids of module points – one slightly higher than the other: arrPtsTop and arrPtsBtm.  again, nothing is drawn to rhino, but the critical positions for the truss are figured out here and stored in two arrays.  Then, finally, at the end of this function, the final method is called which draws elements to rhino based on these two arrays.

the function DrawHynetMatrix looks like the most complicated function in the lot, but in reality it’s job is the simplest.  based on two arrays of module points (defined in functions above), this function draws the desired geometry to rhino.  there’s alot of “weaving” going on here – figuring out which point on one module to connect to which point on the next – but conceptually, things are very straightforward.

Tags: Rhinoscript, structure, student script, tiling, truss

Rhinoscript | Vector Utility Functions


Function VectorProjectedLength(arrSrc, arrDest)
	'' Returns the length of the vector which results from the projection of the source vector onto the destination vector
	VectorProjectedLength = Rhino.VectorDotProduct(arrSrc,Rhino.VectorUnitize(arrDest))
End Function

Function VectorProject(arrSrc, arrDest)
	''Returns the vector which results from the projection of the source vector onto the destination vector
	VectorProject = VectorResize(arrDest,VectorProjectedLength(arrSrc, arrDest))
End Function

Function VectorResize(arrVec, dblSize)
	Dim v : v = Rhino.VectorUnitize(arrVec)
	VectorResize = Rhino.VectorScale(v,dblSize)
End Function

Function Centroid(arrPts)
	Dim cent, n
	cent = array(0,0,0)
	For n=0 To Ubound(arrPts)
		cent = Rhino.VectorAdd(cent, arrPts(n))
	Next
	cent = Rhino.VectorScale(cent, 1/(Ubound(arrPts)+1))
	Centroid = cent
End Function

Function PointInterpolate(arrPtA, arrPtB, t)
	Dim vec
	vec = Rhino.VectorCreate(arrPtB, arrPtA)
	vec = Rhino.VectorScale(vec,t)
	PointInterpolate = Rhino.PointAdd(arrPtA, vec)
End Function

Function ScalePtsAboutCentroid(arrPts, scale)
	Dim cent, tVec
	cent = Centroid(arrPts)
	tVec = Rhino.VectorCreate(array(0,0,0), cent)

	Dim n
	For n=0 To Ubound(arrPts)
		arrPts(n) = Rhino.PointAdd(arrPts(n), tVec)
		arrPts(n) = Rhino.PointScale(arrPts(n), scale)
		arrPts(n) = Rhino.PointAdd(arrPts(n), Rhino.VectorReverse(tVec))
	Next
	ScalePtsAboutCentroid = arrPts
End Function

Function VectorCompare(arrVecA, arrVecB)
	'' compares two vectors, see if they are pointing basically the same way
	VectorCompare = False
	If (VectorProjectedLength(arrVecA, arrVecB) > 0 ) Then VectorCompare = True
End Function

Function DistanceXY(arrPtA, arrPtB)
	DistanceXY = (  (arrPtA(0)-arrPtB(0))^2 + (arrPtA(1)-arrPtB(1))^2  )^0.5
End Function
Tags: Rhinoscript, sample script, utility, vector, vector math

Sunday Script | Cardioid


Option Explicit
'Script written by ksteinfe
Call Cardioid()
Sub Cardioid()
	ReDim arrPoints(50)
	Dim x,y,z
	Dim theta

	'' cardioid
	Dim r
	Dim n
	r = 1
	For n=0 To 50
		theta = (n/50)*Rhino.Pi*4
		x = 2*r*(cos(theta)-.5*cos(2*(theta)))
		y = 2*r*(sin(theta)-.5*sin(2*(theta)))
		z = 0
		arrPoints(n)=array(x,y,z)
	Next
	Rhino.AddCurve(arrPoints)
End Sub
Tags: geometry, graph drawing, Rhinoscript, sample script

Sunday Script | Sort Colors to Layers


Option Explicit
'Script written by ksteinfe
'Script copyrighted by nobody!
'Script version Wednesday, April 23, 2008 12:37:44 PM

Call Main()
Sub Main()
	Dim arrObjects, strObject
	arrObjects = Rhino.GetObjects("select objects")

	Rhino.AddLayer("colorSort")

	Rhino.EnableRedraw vbFalse
	For Each strObject In arrObjects
		Dim lngColor
		lngColor = Rhino.ObjectColor(strObject)

		If Not Rhino.IsLayer(lngColor) Then
			Call Rhino.AddLayer(lngColor, lngColor, True, False, "colorSort")
		End If

		Call Rhino.ObjectLayer(strObject, lngColor)
		Call Rhino.ObjectColorSource(strObject,0)
	Next
	Rhino.EnableRedraw vbTrue
End Sub
Tags: layer management, Rhinoscript, sample script

Pratt | Digitial Futures Group

The Digital Futures Group is a collective of computational design experts teaching at Pratt Institute.

Categories